I'm currently in the process of trying to make a gui that allows players to toggle transformations from Dragon Ball Z. I'm currently working on the Kaioken, which is just a red aura. However, what I seem to have so far does not seem to be working
So I ask, is this script correct?
script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.ParticleEmitterKaioken:clone() fr.Parent = jun.Character.Torso end
EDIT: I have since edited the script with the advice of others, however. Now the problem is it doesn't toggle the particles, but rather duplicates them.
Here's the new script.
local jun = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.ParticleEmitterKaioken:clone() fr.Parent = jun.Character.Torso end if jun.Character.Torso["ParticleEmitterKaioken"].Enabled==true then jun.Character.Torso["ParticleEmitterKaioken"].Enabled=false else jun.Character.Torso["ParticleEmitterKaioken"].Enabled=true end end)
Firstly your button click event is incomplete, you forgot to add end) the end on line 5 ends the if statement so it should look like this
script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.ParticleEmitterKaioken:clone() fr.Parent = jun.Character.Torso end end)
Next it's just a matter of changing the bool value of the particle emitter depending on what its current value is
script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.ParticleEmitterKaioken:clone() fr.Parent = jun.Character.Torso end if jun.Character.Torso["NAME OF PARTICLE EMITTE"].Enabled==true then jun.Character.Torso["NAME OF PARTICLE EMITTE"].Enabled=false else jun.Character.Torso["NAME OF PARTICLE EMITTE"].Enabled=true end end)
This now makes it so that if its on it will turn off and if its off it will turn on
You forgot to end the function lol
script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.ParticleEmitterKaioken:clone() fr.Parent = jun.Character.Torso end end)