Assignment are not allowed in an Expression

Godot 4.2

Question

So I am getting this error saying “assignments aren’t allowed in expressions” I have this script

@onready var ap = $Animations

Var direction = Input.getaxis(‘ui_left’,‘ui_right’)

Move and slide()

updateanimations (direction)

func updateanimations (direction):
If is_on_floor:
If direction ==0
ap.play (‘idel’)
else:
ap.play (‘run’)
else:. ‘’’
If velocity.y =< 0: these are the
ap.play (‘jump’) lines that are causing
the error
‘’’

=< is not an operator. Try <= instead.
See GDScript reference — Godot Engine (stable) documentation in English

1 Like

Since =< starts with = and isn’t followed by another =, Godot treats it as an assignment, like you would assign < 0 to velocity.y.
Change =< to <= and you should be fine.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.