#For some reason my script decided that it knows the game object but only in one function

35 messages · Page 1 of 1 (latest)

wet hull
#

How would I go about troubleshooting this? I am stumped

marsh spear
#

Not the same object both time, the one your mailbox has is not the same as the one with your breakpoint
You can see the Object ID for self is different

wet hull
#

ohhh I see, thank you! 😄

#

Sorry I stilll don't get how do I figure out why it's nil? I did assign them, I changed the code around a little in hopes of that helping but it didn't 😅

marsh spear
#

You can go up the callstack and figure out what object this script is using

#

My guess is you have another object using pop_up_button_manager.gd

#

Or your mailbox creates one at runtime for some reason

#

You can also check the remote view (your hierarchy at runtime) and click on the problematic object and it should select it in the hierachy so you can find it easily

#

Also maybe I should have said this first in case you don't know but self means the object you're currently in (here, the object that has pop_up_button_manager.gd as a script)

wet hull
#

hmm that's odd...mailbox does not make a version of pop_up_button manager, I did make pop_up_button_manager a gllobal script though so perhaps that has something to do with it?

marsh spear
wet hull
marsh spear
#

And where are you setting the value for UI_Master?

wet hull
#

oh wait I'm supposed to set it? I thought it was a global function so it just all references to the same thing?

marsh spear
#

What? x)

#

Where does UI_Master even come from? Is it a class name?

wet hull
#

UI_master is the same thing as pop_up_menu_button_manager (which I should probably rename)

#

I made it a global so it (in my head) could be accessed from the mailbox

marsh spear
#

Oh I see! I forgot autoloads worked like that

wet hull
#

I don't know how else to access a script that's in a different scene 😅

marsh spear
#

So no you don't need to set it but it'll create its own instance of pop_up_button_manager.gd

#

So your issue comes from the fact that you autoload the script instead of autoloading the scene in which you have correctly linked the objects

#

Take my answer with a grain of salt, I haven't used autoloads in a loooong time

wet hull
#

Ahh okay thank you! I will try to autoload the scene and see if that works!

marsh spear
#

You also need to remove it from your actual game scene to prevent duplicates

wet hull
#

haha I noticed!

#

It also made my mailbox unclickable for some reason

#

ah it was because the UI was overlapping the screen and stopping the mouse from reaching

#

that's fixed

marsh spear
#

And did it also fix the original issue?

wet hull
#

I don't know yet, it's giving me a different issue

#

which I think is happening because master is now the node, not the script. So now I need to figure out how to access the script in it's child

#

Yes! All fixed, thank you so much!