game.Players.PlayerAdded:connect(function(p) local leaderstat = Instance.new("Model") leaderstat.Name = "leaderstat" leaderstat.Parent = p local c = Instance.new("StringValue") c.Name = "coords" c.Value = 2 c.Parent = leaderstat end) game.Players.PlayerAdded:connect(function(p) local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = p local hunger = Instance.new("NumberValue") hunger.Name = "Hunger" hunger.Value = 100 hunger.Parent = leaderstats local thirst = Instance.new("NumberValue") thirst.Name = "thirst" thirst.Value = 100 thirst.Parent = leaderstats end) print("here here") player = game.Players.LocalPlayer print("code blue") local e = false if player.Hunger.Value <= 10 then e = true while e do wait(2) player.Character.Humanoid.Health = player.Character.Humanoid.Health - 10 end end if player.Character.Humanoid.Health <= 0 then e = false end
basically, this is for a hunger stat. it does the leaderstats part perfectly, but it doesnt print code blue. it doees print here here, which is why i know the waitforchild is messing up. am i using it wrong? or is it something else?
You do not need to use :WaitForChild() on line 13. Also LocalPlayer wouldn't be a "Child" of player, more like an Instance of it. Player is the first thing made when a player enters the game. So therefore, that is not needed. You can simply define player as
game.Players.LocalPlayer