First off it should be a local script because GUIs are locally designated. secondly Players only contain well, players, no characters. Instead do this (script is now edited):
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character.Humanoid
local text = script.Parent
character.Humanoid.HealthChanged:Connect(function()
text.Text = (math.floor(hum.Health).." / "..hum.MaxHealth.." HP")
end)
player.CharacterAdded:Connect(function(newChr)
chr = newChr
hum = newChr:WaitForChild("Humanoid")
text.Text = (math.floor(hum.Health).." / "..hum.MaxHealth.." HP")
hum.HealthChanged:Connect(function()
text.Text = (math.floor(hum.Health).." / "..hum.MaxHealth.." HP")
end)
end)
1 comment
I want My health to display on my Textlabel and update when it goes down and up