Hi there, I’m helping a friend work on their games UI and I thought that it would be a good idea to script part of it (as far as I’m aware they don’t have a scripter right now), but I can’t figure out how to script a textlabel for the health:
Script:
local plr = game.Players.LocalPlayer
local character = game:FindFirstChild(plr.Character)
character.Humanoid.MaxHealth.Changed:Connect(function()
script.Parent.Text = character.Humanoid.Health .. "/" .. character.Humanoid.MaxHealth
end)
character.Humanoid.Health.Changed:Connect(function()
script.Parent.Text = character.Humanoid.Health .. "/" .. character.Humanoid.MaxHealth
end)
Did originally have it set to this, using CharacterAdded now (thank you!) and it still doesn’t seem to be making a difference unfortunately, plus zero errors in output
You need the CharacterAdded:Wait() because you want the script to wait for the character to fully load, else the humanoid will be nil.
For the health changed part you should use the way that @Emskipo suggested with character.Humanoid:GetPropertyChangedSignal("Health"):Connect(function()