(FIXED) Hurting script don't work

Hello!
I was making a script that will hurt player every second If player do not have any oxygen
But it’s not working
Here is script:

wait(1)
local NoOxygen = false
script.Parent.OxygenLevel:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.OxygenLevel.Value <= 0 then
		NoOxygen = true
	else
		NoOxygen = false
	end
end)
while wait(1) do
	if NoOxygen == true then
		script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 1
	end
end

I don’t getting any error!
Thanks for any help!

You should use instead of ..OxygenLevel.Value <= 0 to ..OxygenLevel.Value == 0.

So it would be,

wait(1)
local NoOxygen = false
script.Parent.OxygenLevel:GetPropertyChangedSignal(“Value”):Connect(function()
if script.Parent.OxygenLevel.Value == 0 then
NoOxygen = true
else
NoOxygen = false
end
end)
while wait(1) do
if NoOxygen == true then
script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 1
end
end

Nope it only hits once and then stop it

You should first remove the loop for checking if NoOxygen is true and damaging the player, this is inefficient, and you could do this in the event.

Anyways, for damaging the player every second, try using a repeat until loop. Damage the player every second until OxygenLevel’s value is >= 0.

script.Parent.OxygenLevel.Changed:Connect(function(value) --Value objects have a different Changed event that only fires when the value property changes
	if value <= 0 then
        repeat
            script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 1
            wait(1)
        until script.Parent.OxygenLevel.Value >= 0
	end
end)

simple

if NoOxygen == true then
while true do
wait(1)
script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 1
end
else
print(“statement has falsed”)
end

Any of these methods don’t working sorry

Well, I fixed the script named Health just instantly healed players so when I want make huritng I need disable that scripted

local NoOxygen = false

local Humanoid = script.Parent.Humanoid

s = 100

local function FuNction1()

NoOxygen = true

end

if script.Parent.OxygenLevel.Value == 0 then

FuNction1()

end

if NoOxygen == true then

repeat s = 100 -1

s = Humanoid.Health

until s == 0

end
here

I already fixed it read name of this topic ok