I've been trying to make a gui allowing players to use transformations from Dragon Ball Z and I decided to start by trying to make what should be the simplest, the Kaioken. I have had success in making the toggle button activate the Kaioken's aura... But clicking the button again doesn't remove the aura but rather duplicates it.
Here's the code.
local jun = game.Players.LocalPlayer script.Parent.MouseButton1Click:connect(function() if jun.Character.Torso:findFirstChild("PwnFire") == nil then local fr = game.lighting.Kaioken:clone() fr.Parent = jun.Character.Torso end if jun.Character.Torso["Kaioken"].Enabled==true then jun.Character.Torso["Kaioken"].Enabled=false else jun.Character.Torso["Kaioken"].Enabled=true end end)
Well, in the click function you used:
if jun.Character.Torso:findFirstChild("PwnFire") == nil then
Considering that you are making a kaioken transformation and you didn't tell us what PwnFire was, I could say that the error is the PwnFire part. Instead of PwnFire it should be Kaioken since you're making a kaioken transformation as shown:
if jun.Character.Torso:FindFirstChild("Kaioken") == nil then
By the way, findFirstChild
is deprecated. Use FindFirstChild
instead.
One last thing is that, you don't need the word "Kaioken" to be in square brackets since it doesn't have any special characters or spaces.
Im pretty sure line 4 be if jun.Character.Torso:FindFirstChild("Kaioken") == nil then... Since you want to check if the player's torso already has "Kaioken" before cloning one into the torso, I dont know what "PwnFire" is but since you said it keeps duplicating the aura that would be the problem, and i personally would use if not jun.Character.Torso:FindFirstChild("Kaioken") then....