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?
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if jun.Character.Torso:findFirstChild( "PwnFire" ) = = nil then |
3 | local fr = game.lighting.ParticleEmitterKaioken:clone() |
4 | fr.Parent = jun.Character.Torso |
5 | 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.
01 | local jun = game.Players.LocalPlayer |
02 |
03 | script.Parent.MouseButton 1 Click:connect( function () |
04 | if jun.Character.Torso:findFirstChild( "PwnFire" ) = = nil then |
05 | local fr = game.lighting.ParticleEmitterKaioken:clone() |
06 | fr.Parent = jun.Character.Torso |
07 | end |
08 | if jun.Character.Torso [ "ParticleEmitterKaioken" ] .Enabled = = true then |
09 | jun.Character.Torso [ "ParticleEmitterKaioken" ] .Enabled = false |
10 | else |
11 | jun.Character.Torso [ "ParticleEmitterKaioken" ] .Enabled = true |
12 | end |
13 | 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
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if jun.Character.Torso:findFirstChild( "PwnFire" ) = = nil then |
3 | local fr = game.lighting.ParticleEmitterKaioken:clone() |
4 | fr.Parent = jun.Character.Torso |
5 | end |
6 | end ) |
Next it's just a matter of changing the bool value of the particle emitter depending on what its current value is
01 | script.Parent.MouseButton 1 Click:connect( function () |
02 | if jun.Character.Torso:findFirstChild( "PwnFire" ) = = nil then |
03 | local fr = game.lighting.ParticleEmitterKaioken:clone() |
04 | fr.Parent = jun.Character.Torso |
05 | end |
06 | if jun.Character.Torso [ "NAME OF PARTICLE EMITTE" ] .Enabled = = true then |
07 | jun.Character.Torso [ "NAME OF PARTICLE EMITTE" ] .Enabled = false |
08 | else |
09 | jun.Character.Torso [ "NAME OF PARTICLE EMITTE" ] .Enabled = true |
10 | end |
11 | 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
1 | script.Parent.MouseButton 1 Click:connect( function () |
2 | if jun.Character.Torso:findFirstChild( "PwnFire" ) = = nil then |
3 | local fr = game.lighting.ParticleEmitterKaioken:clone() |
4 | fr.Parent = jun.Character.Torso |
5 | end |
6 | end ) |