Need some help with some scripts

Godot Version

4.5.1

Question

So for a little break of my main game I’m making a little cup game where you have to pick one of 3 cups there is a guy on a table and you have to pick 3 cups in a row to win but if you pick wrong 3 times game over. I have some code right now but I’m wondering how to randomly pick a number (In this case the winning cup) this is the code

extends AnimatedSprite2D

var lives = 3



func _process(delta: float) -> void:
	if lives == 3:
		$".".play("start")
		$Lives.text = "Lives:3"
	if lives == 2:
		$".".play("wrong 1")
		$Lives.text = "Lives:2"
	if lives == 1:
		$".".play("wrong 2")
		$Lives.text = "Lives:1"
func _on_animation_finished() -> void:
	if animation == "start":
		start_game()


func start_game() -> void:
	lives = 3

	

	if lives == 2:
		play("wrong1")
		$Lives.text = "2"
	elif lives == 1:
		play("wrong2")
		$Lives.text = "1"
	elif lives <= 0:
		play("game_over")
		$Lives.text = "0"

func game_over() -> void:

	play("game_over")
	print("GAME OVER")

func _on_cup_1_pressed() -> void:
	print("CUP 1 PRESSED")



func _on_cup_2_pressed() -> void:
	print("CUP 2 PRESSED")



func _on_cup_3_pressed() -> void:
	print("CUP 3 PRESSED")

You can use randi_range to select a random whole number from 1 to 3

do i just use a if randi_range(1.0, 3.0) then?

You don’t have to use decimal points, it’s a little confusing to do so. Something along these lines.

var random_cup := randi_range(1, 3)
if random_cup == selected_cup:
    print("you win")
else:
    print("you lose, it was in cup #", random_cup)

thanks! that helps alot