How to hide and show a particle effect to this double-jump script?

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

I wanna attach a particle to my character’s double jump but i’m stuck at showing and hiding the effect when the character has jumped on its second jump. I’ve tried many different ways to do this but none of them worked, the closest I’ve gotten was this script here. If you want to suggest a whole different or better script for it then please do! Thanks!

	if Input.is_action_just_pressed("ui_up"):
	if on_ground == true:
		vel.y = JumpP 
		HDJ = false
		on_ground = false

elif on_ground == false && HDJ == false:
	vel.y = JumpP
	HDJ = true
if on_ground == false && HDJ == false && Input.is_action_just_pressed("ui_up"):
	DJ = DJ + 1
	if DJ == 2:
		$Double.visible = $Double.visible
		if on_ground == true:
			DJ = 0
	else: 
		$Double.visible = not $Double.visible
:bust_in_silhouette: Reply From: Magso

You’re not toggling visible correctly. $Double.visible = $Double.visible won’t do anything and $Double.visible = not $Double.visible sets visible to the opposite value. It needs to be $Double.visible = true/false.

However toggling visibility will have the particle simply appear and disappear. For a better effect I’d recommend using $Double.emitting = true/false instead.

Thanks so much! This helped!

J0lt3n | 2019-11-23 14:30