I get the"Invalid operands 'String' and 'int' in operator '=='." error and I don't know why

func shoot ():
	if Input.is_action_just_pressed("Lclick"):
		
		
		rng = str(round(randf() + 1))
		
		if rng == 1:
			anim.play("swing")
		elif rng == 2:
			anim.play("swing2")

rng = str(round(randf() + 1))
replace
rng = round(randf() + 1)

3 Likes

These errors are easy to resolve if you specifically type your variables when you declare them:
var rng:int

Everything about this line is wrong. Use randi_range(1, 2) to generate a random number from 1 to 2, remove the round, remove the str, and find a better name for your variable.