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

How do I make sounds play when a player reaches to that certain hp?

Asked by 4 years ago

How do I make sounds play when the player reaches to the certain hp? doing While True do works but rapidly plays the sound which I don't want at all. I'm stuck and I want to get some help to help me solve this solution.

01local player = game.Players.LocalPlayer
02local Character = player.Character or player.CharacterAdded:Wait()
03local s = Character:WaitForChild("Humanoid")
04 
05wait()
06if s.Health <= 40 then
07    end
08    -- Sound Play
09    script.Parent.Sound:Play()
10    script.Parent.Sound2:Stop()
11    if s.Health >= 50 then
12        -- Sound Stop
13    script.Parent.Sound:Stop()
14    script.Parent.Sound2:Play()
15    end

1 answer

Log in to vote
1
Answered by 4 years ago

If the sound is looped then uncheck it. If not then do this:

01local player = game.Players.LocalPlayer
02local Character = player.Character or player.CharacterAdded:Wait()
03local s = Character:WaitForChild("Humanoid")
04 
05wait()
06 
07if s.Health <= 40 then
08    -- Sound Play
09    script.Parent.Sound:Play()
10    script.Parent.Sound2:Stop()
11    if s.Health >= 50 then
12            -- Sound Stop
13        script.Parent.Sound:Stop()
14        script.Parent.Sound2:Play()
15    end
16end
0
Just realized I had to add a function in it, but that helps on what you sent. thanks. TheBuliderMC 84 — 4y
0
No problem! FrontsoldierYT 129 — 4y
Ad

Answer this question