How does the Random Number Generator work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By AllenTheAlien

I’m trying to make a game where you click on an object and it will change places on the screen using a random number generator. How do make the random number generator work? Also I just started coding, which is why everything is probably wrong. lol

 extends RigidBody2D
    var base_speed = 200
    var acceleration = 50
    var scale_variation = 2
    var motion = Vector2()
    func _ready():
    # Clicks
    func _input(event):
    		var random_motiony = (randi_range(1,600))
    		var random_motionx = (randi_range(1,1024))
    		if event.type("lmb_click"):
    			if $UFO_collision:
    				motion.y = random_motiony
    				motion.x = random_motionx

error(16,34): Method ‘randi_range’ is not declared in the current class.
Condition’ _debug_parse_err_line >=0’ is true.returned: _null

:bust_in_silhouette: Reply From: damncoder

Just write:

var random_motiony = int(rand_range(1,600))