Whats wrong with my script?

  1. What do you want to achieve? I wanna fix the script

  2. What is the issue? there’s a error I don’t fully understand which isn’t playing the animation and something wrong with line 7

  3. What solutions have you tried so far? I have found no solutions cause I don’t understand why it isn’t working!

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local sound = player.PlayerGui:FindFirstChild("LowHealthSound")

while wait() do
	if humanoid.Health <= 20 then
		if sound.Playing == false then
			sound:Play()
		end
	else
		if sound.Playing == true then
			sound:Stop()
		end
	end
end

Screen Shot 2021-06-26 at 12.21.54 PM Screen Shot 2021-06-26 at 12.22.13 PM

never mind i put it in the wrong area