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

Why is my clone duplicating twice?

Asked by 6 years ago

Asked by cooldeath49 0 45 minutes ago Hi helpers, I know I'm really amateur and I suck at scripting, but I currently made a target for target practice that changes its color dependent on its health. However, once it dies, it respawns as normal, but after the second death, it duplicates and two targets appear instead. Help would be appreciated. The script is inside a humanoid root part, which is then inside a model, alongside a whole bunch of other body parts. (ignore the whole color and repeated chunk)

local Target = script.Parent.Parent

local backup = Target:Clone()

while true do

            local Hmd = Target.Humanoid.Health

    Torso.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)

    Head.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)

    RL.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)

    LL.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)

    RA.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)

    LA.Color = Color3.new(1 - (Hmd * 0.01), Hmd * 0.01, 0)



    if Target.Humanoid.Health == 0 then

        wait(2)
    Target:Destroy()
    wait(0.5)
    Target = backup:Clone()

    Target.Parent = game.Workspace


end
    wait(0.1)
end

1 answer

Log in to vote
0
Answered by 6 years ago

It is in a while loop?

0
yes cooldeath49 37 — 6y
0
Also you state before the while loop to clone it.. then in the while loop you clone it again so.. Ind1v1duals 43 — 6y
0
Wait i think because you say Target = backup:Clone() but backup is already cloned Ind1v1duals 43 — 6y
0
OHH i know its because the if Target.Humanoid.Health == 0 then is constantly running cooldeath49 37 — 6y
View all comments (2 more)
0
ok Ind1v1duals 43 — 6y
0
thx for your response, I used a lil bit of it. cooldeath49 37 — 6y
Ad

Answer this question