Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

Just realized I had to add a function in it, but that helps on what you sent. thanks.

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.