im just trying to have a function be called when pressing left or right and when jumping, but it gives me the error in question. here is the related code:
func give_xp (amount):
LegExp += amount
if LegExp >= NextLegLevel:
level_up()
func level_up ():
var overflowXp = LegExp - NextLegLevel
NextLegLevel *= LevelIncreaseRate
LegExp = overflowXp
LegLevel += 1
func _physics_process(_delta):
motion.y += Grav
if motion.y > MFS:
motion.y = MFS
if facing_right == true:
$AnimatedSprite.scale.x = 1
else:
$AnimatedSprite.scale.x = -1
motion.x = clamp(motion.x,-MS,MS)
if Input.is_action_pressed("right"):
motion.x += Acc
facing_right = true
give_exp(amount)
elif Input.is_action_pressed("Left"):
motion.x -= Acc
facing_right = false
$AnimatedSprite.play("Walking")
else:
motion.x = lerp(motion.x,0,0.2)
$AnimatedSprite.play("Idle")
adding giveexp(amount) into if Input.isaction_pressed("right"): is when I get the error