Identifier not declared in current scope and I don't know what to do

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nutkicker12

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 give_exp(amount) into if Input.is_action_pressed(“right”): is when I get the error

:bust_in_silhouette: Reply From: xJM27x

When you call a function with parameters like
do_something(param1, param2, param3, …)

You replace the parameters with the values you want to be used.

For example in your case, you should change the parameter “amount” into an actual value as you call it.
give_exp(10)

yeah that did it thanks

nutkicker12 | 2021-01-04 20:07

:bust_in_silhouette: Reply From: AlexTheRegent

Your function have name give_xp, while you are trying to call give_exp function. So either name your function give_exp or call it by give_xp(amount)

i tried both solutions you gave but i still get the error. it doesnt like the ‘amount’ part and if i get rid of that it then says too few arguments for the function to be called.

nutkicker12 | 2021-01-04 17:37