So basically, I am trying to make a TextLabel show the health the player currently has, but it’s not quite working.
When I load into the game, it shows my health at “100”, which is what I coded it to do. But it starts going downhill when I change the Player’s HP and see the TextLabel not change at all. It just stayed at 100.
I have tried a couple of things, but to no avail.
The script is listed below:
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
script.Parent.Text = "100"
character.Humanoid.HealthChanged:Connect(function(health)
script.Parent.Text = health
end)
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local label = script.Parent
label.Text = humanoid.Health
humanoid.HealthChanged:Connect(function(newHealth)
label.Text = newHealth
end)