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 3 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.

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local s = Character:WaitForChild("Humanoid")

wait()
if s.Health <= 40 then
    end
    -- Sound Play
    script.Parent.Sound:Play()
    script.Parent.Sound2:Stop()
    if s.Health >= 50 then
        -- Sound Stop
    script.Parent.Sound:Stop()
    script.Parent.Sound2:Play()
    end

1 answer

Log in to vote
1
Answered by 3 years ago

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

local player = game.Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()
local s = Character:WaitForChild("Humanoid")

wait()

if s.Health <= 40 then
    -- Sound Play
    script.Parent.Sound:Play()
    script.Parent.Sound2:Stop()
    if s.Health >= 50 then
            -- Sound Stop
        script.Parent.Sound:Stop()
        script.Parent.Sound2:Play()
    end
end
0
Just realized I had to add a function in it, but that helps on what you sent. thanks. TheBuliderMC 84 — 3y
0
No problem! FrontsoldierYT 129 — 3y
Ad

Answer this question