Error parsing expression, misplaced ":"

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

The error is at “else:”, I don’t know why this error suddenly came? It wasn’t there earlier and I haven’t changed anything

Feel free to ask questions about the code, if it’s hard to read

if Input.is_action_pressed("fire"):
	if head.rotation.x < 1.55:
		if isAiming == false:
			head.rotation.x += 0.005
			head.rotation.x += 0.001
	if not anim_player.is_playing():
		if raycast.is_colliding():
			var target = raycast.get_collider()
			if target.is_in_group("Enemy"): -= (damage *"AssaultFire")
:bust_in_silhouette: Reply From: Juxxec
 if target.is_in_group("Enemy"):
   -= (damage *"AssaultFire")

You are missing a ‘)’ at the end. It should be:

 if target.is_in_group("Enemy"):
   -= ( damage *"AssaultFire") )

Also, you cannot multiply health with"AssaultFire"), as pointed out by Gluon

thank you so much

kooczsi | 2022-11-28 08:50

:bust_in_silhouette: Reply From: Gluon

I think the issue is actually at your line -= (damage * 

there should be something after the * and a closing bracket, try changing it to this to see if the error goes away -= (damage * 1)

thank you too, i dont know how that even happened

kooczsi | 2022-11-28 08:51

@Gluon that part is okay. When you have the brackets (), you can split your code into multiple lines and it will execute without errors. However, without the brackets, you need to use \ at the end of the line or it will not work.


var total_damage = (50 *


var total_damage = 50 * \


var total_damage = 50 *

Juxxec | 2022-11-29 11:12

That part is not okay. You cannot mulitply by an animation play function and even if you could there is a missing bracket ).

Gluon | 2022-11-29 18:22

Oh you are correct. Didn’t see that he was doing that

Juxxec | 2022-12-01 08:28