So I am trying to display the players health this is what I tried but there are no errors or anything in the output
Local Script:
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local text = script.Parent.Text
while true do
text = hum.Health .. ""
wait(0.00001)
text = hum.Health .. ""
end
Don’t save the instance’s property, as it saves the value instead of the location/index, so when you are trying to change the text it only changes the variable and not the TextLabel’s property
local players = game:GetService("Players")
local player = players.LocalPlayer
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local label = script.Parent --save the instance instead, the game assumes you are saving the text and not the property location
hum:GetPropertyChangedSignal("Health"):Connect(function() --this event fires whenever the "Health" property changes
label.Text = hum.Health .. ""
end)
Yeah, so this is pretty much all you have to do
(Updated Version of @mniao )
local player = game.Players.LocalPlayer
local hum = player.Character:WaitForChild("Humanoid")
local text = script.Parent.Text
text = hum.Health -- Extra Security to set text to health
hum:GetPropertyChangedSignal("Health"):Connect(function()
text = hum.Health
end