Low Health Heartbeat effect not working

Hi there! So what I’m trying to achieve is a heartbeat effect where basically is the character health is low, there will be a heartbeat sound that plays, and the lower the health, the faster the sound plays. I’ve had a tough time figuring how to achieve this, current having issues with this script:

player = game.Players.LocalPlayer
local Humanoid = player.Character:FindFirstChild('Humanoid')
local HeartBeatSound = script.Parent.HeartBeatSound
while true do
	if Humanoid.Health <=60 then -- o no! low health!
		HeartBeatSound:play()
		wait(1)
	end
	if Humanoid.Health >=51 then
		wait(0.4)
	end
	if Humanoid.Health <=0 then
		wait(5)
	end
end

1 Like

The humanoid doesn’t exist yet.

local player = game.Players.LocalPlayer;
local Humanoid = (player.Character or player.CharacterAdded:Wait()):WaitForChild("Humanoid");
-- continue code.
3 Likes