# How do I move my position 2d??????

Attention Topic was automatically imported from the old Question2Answer platform.
``````extends Position2D

var rngx = RandomNumberGenerator.new()
var rngy = RandomNumberGenerator.new()
func _on_Button_button_down() -> void:
var x = int(rngx.randf_range(0,1024))
var y = int(rngy.randf_range(0,600))
\$self.position(x,y)
``````

Whenever I put this code in it give me the error, Attempt to call function ‘position’ in base ‘null instance’ on a null instance.
What am I doing wrong? How should I fix it?

make this:

``````var x = int(rngx.randi_range(0,1024))
var y = int(rngy.randi_range(0,600))
``````

``````var x = int(rngx.randf_range(0,1024))
var y = int(rngy.randf_range(0,600))
``````

This error cause beacause randf_range takes float number (f in randf means float) and you wrote integer number.
And \$self (last line) make it self without dollar sign

This is my code now:

``````extends Position2D

var rngx = RandomNumberGenerator.new()
var rngy = RandomNumberGenerator.new()

func _on_Button_button_down() -> void:
var x = int(rngx.randi_range(0,1024))
var y = int(rngy.randi_range(0,600))
self.position(x,y)
``````

The hierarchy:

When I put this code in I get an error saying: E 0:00:01.280 emit_signal: Error calling method from signal ‘button_down’: ‘Button(Button.gd)::_on_Button_button_down’: Method not found…
<C++ Source> core/object.cpp:1242 @ emit_signal()

Vickyboi | 2022-09-03 23:38