Hey guys, so I asked another question a few hours ago, and a problem popped up through it.
So I have this script, which is supposed to be like an oxygen tank, and when you reach 0 oxygen, it hurts you.
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild("Humanoid")
local air = script.Parent
while wait(1) do
if Character:FindFirstChild("SmallAir") then
air.Value = air.Value - 1
if air.Value > 0 then
print(air.Value.." air remaining.")
else
print("No air remaining!")
Humanoid.Health = Humanoid.Health - 10
end
end
end
However, it always gives me the error of "attempt to index nil with 'Health'" It seems that this is not just a problem with the health, because I've tried to do print(Humanoid.Parent.Name) and it tells me that Parent is the nil value. Any specific reason?

5 comments
Script or localscript?
localscript
Try "Humanoid:TakeDamage(10)"
Now it says that TakeDamage is nil
look at my answer it may help you