Unexpected token if I don't know how to solve it

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Бен Брэмхолл

I don’t know what I did wrong so I need help.

my code is:

if is_jumping
_velocity.y = jump_strength
_snap_vector = Vector3.ZERO
elif just_landed:
_snap_vector = Vector3.DOWN
_velocity = move_and_slide_with_snap(_velocity, _snap_vector, Vector3.UP, true)

if _velocity.length() > 0.2:
	var look_direction = Vector2(_velocity.z, _velocity.x)

func _process(_delta: float) → void:
_spring_arm.translation = translation

What error are you getting?

Gluon | 2022-11-26 21:25

I figuered out how to solve this, but I have another issue where it says error parsing expression, misplaced: elif

Бен Брэмхолл | 2022-11-26 22:22

Oh well the new error should be easy to solve. The error itself should tell you which line it is referring too. Your elif must not be valid in an if block, maybe it isnt tabbed in correctly or something similar.

Gluon | 2022-11-26 22:38

Thank you it worked but now it says the same thing but for func

Бен Брэмхолл | 2022-11-27 01:01

nvm I fixed that as well

Бен Брэмхолл | 2022-11-27 03:53

Can you mark this question as answered?

Juxxec | 2022-11-27 11:44

:bust_in_silhouette: Reply From: LordBoots

It seems you’re struggling with simple syntax errors.

My solution would be to do 4-6 hours of python tutorials as it’s the closest language to GD script. This should help you with your own troubleshooting in the future. I would say you’re having issues keeping track of indents which is very common when starting out with any language (Especially C languages)

Start Here

Wakatta | 2022-12-03 15:44