1 | local player = script.Parent.Parent.Parent.Parent.Parent.Parent |
2 | local character = player.Character |
3 | local humanoid = character:FindFirstChild( "Humanoid" ) |
4 | local labelText = script.Parent |
5 |
6 | while true do |
7 | labelText = humanoid.Health.. "/" ..humanoid.MaxHealth |
8 | wait() |
9 | end |
Thanks :D
""..humanoid.Health.."/"..humanoid.MaxHealth..""
01 | local player = game.Players.LocalPlayer --replaced as this is better/easier. |
02 | repeat wait() until player.Character --Waits for the character to load. You'll need this or else it won't work in game, only for studio. |
03 | local character = player.Character |
04 | local humanoid = character:WaitForChild( "Humanoid" ) --Changed to WaitForChild as it will wait for Humanoid |
05 | local labelText = script.Parent |
06 |
07 | humanoid.Health.Changed:connect( function () --This is better as it will not run a continous loop and cause lag. |
08 | labelText.Text = humanoid.Health.. "/" ..humanoid.MaxHealth --This was the problem as well, you didn't have the .Text so it wouldn't do anything |
09 | end ) |
10 |
11 | --This should be a local script btw, I noticed you use the game.Parent.Parent etc, but you could simply do game.Players.LocalPlayer. |