I need to access a player’s health value so I can change it, and i have this localscript in starterplayerscripts:
wait(0.1)
local player = game.Players.LocalPlayer
local playername = game.Players.LocalPlayer.Name
local playerchar = player.Character
local humanoid = playerchar.Humanoid
local hunger = player.Hunger
while true do
wait(3)
hunger.Value = hunger.Value - 1
end
When I run the game, it gives this error message:
Players.Quantapie.PlayerScripts.Hunger:9: attempt to index nil with 'Humanoid'
Also, I have another localscript in screengui,
wait(0.1)
local health = script.Parent
local player = game.Players.LocalPlayer
local playername = game.Players.LocalPlayer.Name
local playerchar = player.Character
playerchar.Humanoid.Changed:Connect(function()
health.Value = playerchar.Humanoid.Health
end)
and for some reason that has no problems. Anyone know why? Any help would be appreciated. Thanks!

2 comments
I need to see your explorer
Do: "local playerchar = player.Character or player.CharacterAdded:Wait()"