Var rotate = randi() % 2 == 0 ? -1 : 1

Godot Version

4.2.1

Question

var rotate = randi() % 2 == 0 ? -1 : 1

but next error: Unexpected “?” in source. If you want a ternary operator, use “truthy_value if true_condition else falsy_value”.
Expected end of statement after variable declaration, found “Literal” instead.

Ternary operator are written differently in GDScript, as the error mention you need to use “truthy_value if true_condition else falsy_value” so correcting your line the result is:

var rotate = -1 if randi() % 2 == 0 else 1

For sure you don’t need it anymore, but as I kept arriving here when I forgot the right syntax for the ternary operator in GDScript, I prefer to put the answer for you, my future self and for everyone else just in case.