I am following an inventory system tutorial by Gwizz (Link: https://www.youtube.com/watch?v=2ZauOcB_jBw) At 12:38 is where the issue arises. He clicks the item and it goes into the slot, but when I click my item, nothing happens. I already made sure we’re on the same version, and I’m pretty sure all the code and nodes is the same (Though admittedly I may have missed something) Thoughts? I can provide screenshots if needed. Any help would be very much appreciated.
I see just one print() statement. That’s not nearly enough to understand what’s going on. You need to add it at different stages of the code to make any meaningful difference. You said it didn’t send the message (I assume you mean to call a function) - then try to see if that function is ever being called, so add a print() statement right before that function call. And so on and so forth, until you find the culprit.
Okay. Using that I believe the issue is that in the below, it isn’t detecting the button being pressed. I think. (I’ve only been coding for like a month, so forgive me if I seem dense)
Thanks. And the error says ‘ERROR: Signal ‘pressed’ is already connected to given callable ‘Node2D(gem.gd)::_on_button_pressed’ in that object.’ because I thought it may not have been connected, so I clicked it again, and it sent this error because it was, in fact, connected.
So what happens when you click the button? Is anything printed to the console? Does the Button react visually to your presses?
Btw - make your prints more meaningful than just having “works” everywhere. Because now if it prints “works” - you don’t really know what works. Even just adding unique numbers to each will help - “works 1”, “works 2”, etc. so that you can differentiate it in the console. Ideally it should be something more meaningful though.
When I click the button it is outlined in white, so I think it detects the click, but it’s not triggering the code, for some reason? Also, I just changed ‘works’ to ‘Button works’.
Can you try adding this piece of code to the Button node directly? And then click the button and see if “Button pressed” is printed in the console when clicking.
Then there’s something fundamentally wrong.
Can you try to isolate the issue? Create a scene where only 1 Button exists and nothing else, put this script on the Button, run the scene, click the Button, check if it prints anything to the console.
Ok, that’s good.
Then try to recreate your original item scene from scratch and see at what point it’ll break (or hopefully not). Then you can pinpoint the issue.