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.
01 | local player = game.Players.LocalPlayer |
02 | local Character = player.Character or player.CharacterAdded:Wait() |
03 | local s = Character:WaitForChild( "Humanoid" ) |
04 |
05 | wait() |
06 | if s.Health < = 40 then |
07 | end |
08 | -- Sound Play |
09 | script.Parent.Sound:Play() |
10 | script.Parent.Sound 2 :Stop() |
11 | if s.Health > = 50 then |
12 | -- Sound Stop |
13 | script.Parent.Sound:Stop() |
14 | script.Parent.Sound 2 :Play() |
15 | end |
If the sound is looped then uncheck it. If not then do this:
01 | local player = game.Players.LocalPlayer |
02 | local Character = player.Character or player.CharacterAdded:Wait() |
03 | local s = Character:WaitForChild( "Humanoid" ) |
04 |
05 | wait() |
06 |
07 | if s.Health < = 40 then |
08 | -- Sound Play |
09 | script.Parent.Sound:Play() |
10 | script.Parent.Sound 2 :Stop() |
11 | if s.Health > = 50 then |
12 | -- Sound Stop |
13 | script.Parent.Sound:Stop() |
14 | script.Parent.Sound 2 :Play() |
15 | end |
16 | end |