Goal:
Each player’s hunger value will show on their screen. (Like this, but it updates whenever the IntValue changes and everyone gets their own)
my script:
I’m not sure on how to make the IntValue equal to the TextLabel. Since each player has their own one which they get when the game starts, I do not know how to reference it.
Here is what I tried, though. I would love it if someone showed me a better method!
game.Players.PlayerAdded:Connect(function(plr)
local playerWellness = Instance.new("Folder")
playerWellness.Name = "Wellness"
playerWellness.Parent = plr
local hunger = Instance.new("IntValue")
hunger.Name = "Hunger"
hunger.Parent = playerWellness
hunger.Value = 100
local GuiText = hunger.Value
GuiText.Changed:Connect(function()
local hungerValue = game.StarterGui.ScreenGui.Hunger.hungerValue
hungerValue.Text = hunger.Value
end)
end)
Information:
- Everything else works, the value updates appropriately
- there are no errors in the output
- if you are wondering the point of playerwellness, there’s a purpose for that (i followed a tutorial)