Error on every single function call > "Attempt to call function 'queue_free' in base 'null instance' on a null instance."

Hello,

i’m having a brain twister here and i’m losing my mind over it.

I have a rather simple script where i’m trying to call a built in function on a node and i’m getting the “Attempt to call function ‘queue_free’ in base ‘null instance’ on a null instance.” error.

Thing is, i’m having this error no matter what node i’m referencing on the first place.



I understand why it returns that error as “campaign_ui” has “null” for a value but given that i referenced if by dragging it on the script and pressing Ctrl while dropping it in, this makes no sense to me.

I used queue_free() as an example but any and every function called upon a node referenced in that way returns the same error. The only way i could make such a call work is buy calling a function on the Campaign_Manager node itself.

I suspect a pathing issue but i’m clueless on how to fix it as i never had any such issue when dragging + holding Ctrl to reference a node.

This is particularly frustrating as i have another scene setup exactly the same that works perfectly and i can’t spot any difference(s).

NB: the rest of the script is a bunch of empty functions and signals i have setup for later, here it is anyway if this is relevant: AgroCampaign_Game_Manager

Its advisable to access siblings (and children of siblings) with “@export” or through the parent instead of onready, because of the mentioned pathing problems. These pathing problems could possibly be avoided, by calling

add_child(Twin_princes_agro_packed, true)

add_child but with force_readable_name set to true

Before queue_free in ready function, redefine the campaign ui, like this:

var campaign_ui = $"../UI/Campaign_UI" #In ready function

I’m not sure on how to do that tbh, do you know of any tutorial out there that can help me understand and apply that? :slight_smile:

i tried this with no effect, i had the same error as before :confused:

I seem to have identified the problem. I figured that since i moved some of the files in the project tree, the pathing might be off.

I deleted the script file and erased all dependencies, i then recreated the script and it worked just fine.

I guess it’s better not to move files around inside the project files tree

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.