ERROR:SCRIPT: Bad argument #1 to 'pick_node' (userdata expected, got nil) (SOLVED)

Hi,

I am very new to Defold and am learning lua as I go. I have created a node named ‘Button’ and I want the user to click the button to display text. Eventually, this will become a button that, when pressed, displays an image.
It is detecting the user’s input but spits out the below error:

function init(self)
	msg.post(".", "acquire_input_focus")
end

function on_input(self, action_id, action)
	if action_id == hash("Mouse") and action.pressed then
		local button = gui.get_node("Button")
		if gui.pick_node(Button, action.x, action.y) then
			--ERROR:SCRIPT: /main/Scripts/Button.gui_script:8: bad argument #1 to 'pick_node' (userdata expected, got nil)
			print("Congrats you clicked it")
		end
	end
end

What am I doing wrong?
Thanks!!

Badgerous

1 Like

Button and button, not same variable).

8 Likes

Excellent!!! Thank you @d954mas. Works fine now. Now I know I need to check the spelling of variables. :smile:

2 Likes