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?

01P = script.Parent.Parent.Parent.Parent.Character.Humanoid
02while true do wait(0.1)
03if P.Health == 0 then
04script.Parent.Visible = true
05math.random
06script.Parent.Script.Death:play()
07script.Parent.Script.Death2:play()
08wait(100)
09end
10wait()
11end

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:

01game.Players.PlayerAdded:connect(function(plr)
02plr.CharacterAdded:connect(function(char)
03repeat wait() until char.Humanoid
04char.Humanoid.Died:connect(function()
05a = script.Death:clone()
06a.Parent = plr.PlayerGui
07b = script.Death2:clone()
08b.Parent = plr.PlayerGui
09repeat a:Play() b:Play() until a.Playing == true and b.Playing == true
10end)
11end)
12end)

Just make this a script in workspace, and add your sounds into that script.

Ad

Answer this question