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

Play Sound On Death?-Need Fix PLZ?

Asked by 10 years ago

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

1 answer

Log in to vote
2
Answered by 10 years ago

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.

Ad

Answer this question