Hello everyone. Godot beginner here. So I try to make a 2D game and I have a dice that waits until player moves his mouse inside the dice collision and then right click to roll the dice. I use an Area2D node and the signal _on_area_2d_mouse_entered to know when the mouse is inside the dice, although I can't find a way to get input inside the signal so the player can right click and roll the dice.

# Mouse Entered Dice
func _on_area_2d_mouse_entered():
	print("Dice Texture : ", $Sprite2D.get_texture())
	if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
		var rng = RandomNumberGenerator.new()
		var dice_choice = rng.randi_range(1, 6)
		var dice_path = "res://sprites/dice/dice_" + str(dice_choice) + ".png"
		$Sprite2D.texture = load(dice_path)

    GameDevWannaBe Put a print statement inside if block as well. Then observe what gets printed out. It will give you some clues on where the problem might be.

    Update: This works but I don't like it a lot

    var isEnteredInDice = false
    # Mouse Entered Dice
    func _on_area_2d_mouse_entered():
    	isEnteredInDice = true
    
    func _on_area_2d_mouse_exited():
    	isEnteredInDice = false
    
    
    func _input(event):
    	if event.is_action_pressed("mouse") and isEnteredInDice:
    		var rng = RandomNumberGenerator.new()
    		var dice_choice = rng.randi_range(1, 6)
    		var dice_path = "res://sprites/dice/dice_" + str(dice_choice) + ".png"
    		$Sprite2D.texture = load(dice_path)

    The "mouse" action is just a Right-click action

      GameDevWannaBe that's just how coding works, but you could use has_point instead of signals to manually check if the mouse is inside the shape on each click:

      func _input(event):
      	if event.is_action_pressed("mouse") and is_mouse_inside_dice():
      		var rng = RandomNumberGenerator.new()
      		var dice_choice = rng.randi_range(1, 6)
      		var dice_path = "res://sprites/dice/dice_" + str(dice_choice) + ".png"
      		$Sprite2D.texture = load(dice_path)
      
      func is_mouse_inside_dice():
              return $Area2D/CollisionShape2D.shape.get_rect().has_point(slef.get_global_mouse_position())

        GameDevWannaBe var rng = RandomNumberGenerator.new()

        Don't create a new RandomNumberGenerator every time you need a random number. Create the RNG once. Or use the default one.