Invalid get index 'weight' (on base: 'null instance'). showing up

Godot Version

4

Question

Hello, I am very new to programming with godot and I have been running over an error I tried to fix for hours now. I'm trying to access an export variable using a line of code but the debugger keeps saying he couldn't find the Node. I tried to follow steps from other people who had the same problem as me but with no success. Here is the code and Node path:

Your images look pretty bad but everything seems fine.
You don’t know which node is null.
To see which node is missing and get a little clue, first do:

	var disctyes = get_node("Disctypes")
	if disctypes == null:
		print("disctypes is null")
	else:
		var regularDisc = dictypes.get_node("RegularDisc")
		if regularDisc == null:
			print("regularDisc is null")


Another option to access the RegularDisc node is to mark it as “% Access As unique name” and then you can do: get_node(“%RegularDisc”) regardless of where it is located in your scene.

You should put more clearly the code from which you access that node.

I thank you for your advice and helpful information, to my surprise tho I had figured it out a few hours after I queued this post for approval: The path was right, however I tried to access the node before the “_ready()” function which basically means I tried to access nodes before they were even fully added to the tree which of course led to an error. In the future I will watch out where I put certain code like this one…

1 Like

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