Hello, I was making Hunger bar. I want to do this When you ate something, your Hunger.Value will + Its a Tool.
local Tool = script.Parent Tool.Handle.DrinkSound:Play() local player = Tool.Parent if game.Players.LocalPlayer[player.Name].currHunger.Value <300 then game.Players.LocalPlayer[player.Name].currHunger.Value = game.Players.LocalPlayer[player].currHunger.Value +100 if game.Players.LocalPlayer[player.Name].currHunger.Value >300 then game.Players.LocalPlayer[player.Name].currHunger.Value = 300 end end if game.Players.LocalPlayer[player.Name].currHunger.Value >300 then game.Players.LocalPlayer[player.Name].currHunger.Value = 300 end
You are accessing player.Name
for some reason. game.Players.LocalPlayer
is the actual player object, so if currHunger
is a child of the player, you can just reference game.Players.LocalPlayer.currHunger
. I recommend adding an Instance:WaitForChild()
call for currHunger
, however.