Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to make toggle-able Kaioken... Instead it duplicates... Little Help?

Asked by 6 years ago

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)

0
:findFIrstChild is deprecated, so as :connect. Also, make variables mean something. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

0
Thank you, it works perfectly now! DerpzGamez 6 — 6y
0
My next step is to try to throw custom hats into the mix, I'll see where I go with that. DerpzGamez 6 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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....

0
Use code blocks or inline code, please. GoldenPhysics 474 — 6y
0
:( sorry, I'm new to this site i don't know how Darkage_1 0 — 6y
0
And im on mobile... Darkage_1 0 — 6y

Answer this question