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

**URL:** <https://forum.defold.com/t/error-bad-argument-1-to-pick-node-userdata-expected-got-nil-solved/40511>\
**Category:** Questions\
**Created:** [January 15, 2019, 4:03am UTC](https://forum.defold.com/t/error-bad-argument-1-to-pick-node-userdata-expected-got-nil-solved/40511 "2019-01-15T04:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Badgerous](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/b/f4b2a3/32.png) [@Badgerous](https://forum.defold.com/u/Badgerous)\
**Post date:** [January 15, 2019, 4:03am UTC](https://forum.defold.com/t/error-bad-argument-1-to-pick-node-userdata-expected-got-nil-solved/40511/1 "2019-01-15T04:03:55Z")

</div>

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:

```lua
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

---

<div class="post-metadata">

**Author:** ![d954mas](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/d954mas/32/5401_2.png) [@d954mas](https://forum.defold.com/u/d954mas)\
**Post date:** [January 15, 2019, 7:06am UTC](https://forum.defold.com/t/error-bad-argument-1-to-pick-node-userdata-expected-got-nil-solved/40511/2 "2019-01-15T07:06:25Z")

</div>

> [@Badgerous](#):
>
> ```lua
> local button = gui.get_node("Button")
> If gui.pick_node(Button, action.x, action.y) then
> 
> ```

Button and button, not same variable).

---

<div class="post-metadata">

**Author:** ![Badgerous](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/b/f4b2a3/32.png) [@Badgerous](https://forum.defold.com/u/Badgerous)\
**Post date:** [January 15, 2019, 8:48am UTC](https://forum.defold.com/t/error-bad-argument-1-to-pick-node-userdata-expected-got-nil-solved/40511/3 "2019-01-15T08:48:50Z")

</div>

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