Infinite Yield Possible on WaitForChild("IsDrown")

I want to make an oxygen system.
It just won’t work. It’s supposed to make the meter go down when underwater, i already have the underwater part working, THIS WONT WORK THOUGH.

local IsDrown = script.Parent:WaitForChild("IsDrown")
local oxygen = script.Parent:WaitForChild("oxygen")
local plrgui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')

IsDrown.Changed:Connect(function()
	print("mhm")
	if IsDrown.Value == true then
		print("alr")
		repeat
			if IsDrown.Value == true then
				print("ohk")
				wait(1)
				oxygen.Value = oxygen.Value - 1
				plrgui.Oxygen.TextLabel.Text = "oxygen: ".. oxygen.Value
			end
		until oxygen.Value <= 0
	end
end)

HELP

1 Like

It means it can’t find that value

No, I know, but like it is supposed to.

Show me the hierarchy of your script / values if you can

game, players, me(player), IsDrown.

I meant an image like this of how yours looks like
image

I’m going to be completely honest, I can’t find any screenshots on my PC, lol. I can’t find them after I take them

No problem does yours look like my first image or like this, with the value inside the script
image

No, the value is inside the player.

And your script is in the player as well or elsewhere?

I’m an idiot. The script is inside something inside the player. Thank you so much Nitefal. Hope you have a wonderful day.

Happens to the best of us. no problem, take care

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.