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

Only plays once?

Asked by
drahsid5 250 Moderation Voter
10 years ago

I made a script that has a GUI animation when my fake health integer <= 0 It works once, perfectly then when the value reaches 0 again, it doesn't even make the GUI visible. Anyone know why?

local World = script.Parent.Parent.Parent.InWorld
local DeathMessages = {
    "You failed..."
    ,"Epic fail!"
    ,"HAHAHAHAHAH! YOU DIED!"
    ,"Try again."
    ,"NOOOOOO!"
    ,"Try to stay alive this time? Kthx."
    ,"Y'know... Irl... YOLO!"
    ,"Your so good at this game."
    ,"You did it! YOU DIED!"
    ,"Don't look into the light!"
    ,"WHY?!?!??!?!"
    ,"Uhg..."
    ,"Good job!"
    ,"Newb..."
    ,"SPOOOOOOON!"  
    ,"You died? lolno rly?"
    ,"You died? YOUR NOT JOKING?"
    ,"o.o"
    ,"ASDFGHJ"
    ,"RAAAAAAAAAAAAAAAAAAAAAGE!!!!"
    ,"You Only Live Once, you let it go to waste."
    ,"Go for em'"
    ,"TROLOLOLOLO!!!!!!!!!"
    ,"Umad bro?"
    ,"If you don't succeed, try, try again."
    }


while true do
if script.Parent.Parent.Health.Value <= 0 then
local RndMsg = DeathMessages[math.random(1,#DeathMessages)]
script.Parent.Fail.Text = RndMsg
    script.Parent.Visible = true
    script.Parent.Fail.Position = UDim2.new(-1,0,0.5,0)
    script.Parent.GameOver.Position = UDim2.new(0.5,0,-1,0)
    wait(0.2)
    script.Parent.GameOver:TweenPosition(UDim2.new(0.5,0,0.425,0), "Out", "Quad", 4)
    script.Parent.Fail:TweenPosition(UDim2.new(0.5,0,0.5,0), "Out", "Quad", 3.25)
    wait(3)

while wait(3) do 
for i=1, 45 do
for i=1, 4 do
    script.Parent.GameOver.Rotation = script.Parent.GameOver.Rotation -1
    wait(0.01)
for i=1, 4 do
        script.Parent.GameOver.Rotation = script.Parent.GameOver.Rotation +1
    wait(0.01)
    end
wait(0.0001)
end
for i=1, 13 do
        script.Parent.GameOver.Rotation = (script.Parent.GameOver.Rotation +1)
wait(0.01)
end
script.Parent.GameOver:TweenPosition(UDim2.new(0.5,0,1.1,0), "Out", "Quad", 1.5)
wait(5)
script.Parent.Visible = false
script.Parent.GameOver.Rotation = 0
if script.Parent.Parent.Health.Value <= 0 then
game.Players.LocalPlayer.Character.Torso.CFrame = CFrame.new(game.Workspace[World.Value].SpawnPoint.Position + Vector3.new(0,3,0))
script.Parent.Parent.Health.Value = script.Parent.Parent.MaxHealth.Value
end

end
end
end
wait()
end

1 answer

Log in to vote
1
Answered by 10 years ago

It is because you are not cloning that GUI. You are re-parenting it from what I can see.

That makes it so it removes from the game once that player resets. Try cloning the GUI, instead of re-parenting

Ad

Answer this question