Notes ~ this is inside StarterPlayerScripts, which has an Integer Value named "Air", this is a local script inside of "Air"
Hey all, so I'm trying to make a game where you have a set amount of oxygen and when you run out it starts to damage you. So I made the first part work
local player = game.Players.LocalPlayer -- getting the player
local air = script.Parent -- the IntValue
while wait(1) do -- every one second
if air.Value > 0 then -- check if any air is remaining
air.Value = air.Value - 1 -- subtract an air
print(air.Value.." air remaining.") -- print the air remaining
end
However, when I made some modifications to the script (see below), it stopped working and gave me this error
Players.v1rtical.PlayerScripts.Air.LocalScript:3: attempt to index nil with 'FindFirstChild'
Here is the new (broken) script
local player = game.Players.LocalPlayer
local air = script.Parent
local humanoid = player.Character:FindFirstChild("Humanoid")
while wait(1) do
if air.Value > 0 then
air.Value = air.Value - 1
print(air.Value.." air remaining.")
else
print("No air remaining!")
humanoid.Health = humanoid.Health - 10
end
end
Hope someone can help, thanks!!

3 comments
change it to WaitForChild
change it to WaitForChild
I've done that and it gives me the same error but replaces "FindFirstChild" with "WaitForChild"