P = script.Parent.Parent.Parent.Parent.Character.Humanoid while true do wait(0.1) if P.Health == 0 then script.Parent.Visible = true math.random script.Parent.Script.Death:play() script.Parent.Script.Death2:play() wait(100) end wait() end
✓ ANSWER ACCEPTED
Play Sound On Death?-Need Fix PLZ?
1 answer
✓ Accepted answer
Just to make it easier... for me, lets run through this shall we?
P = script.Parent.Parent.Parent.Parent.Character.Humanoid
while true do wait(0.1)
if P.Health == 0 then
script.Parent.Visible = true
math.random
script.Parent.Script.Death:play()
script.Parent.Script.Death2:play()
wait(100)
end
wait()
end
Notice why is there a math.random? That's my question, also you don't need a wait 0.1 or a wait(100) afterwards. Just do this:
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
repeat wait() until char.Humanoid
char.Humanoid.Died:connect(function()
a = script.Death:clone()
a.Parent = plr.PlayerGui
b = script.Death2:clone()
b.Parent = plr.PlayerGui
repeat a:Play() b:Play() until a.Playing == true and b.Playing == true
end)
end)
end)
Just make this a script in workspace, and add your sounds into that script.
This discussion is preserved as it was. New answers, comments, and votes are closed.
