Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Humanoid health won't print into Gui?

local player = script.Parent.Parent.Parent.Parent.Parent.Parent
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
local labelText = script.Parent

while true do
labelText = humanoid.Health.."/"..humanoid.MaxHealth
wait()
end

Thanks :D

1 comment

1

It should be labelText.Text = humanoid.Health.."/"..humanoid.MaxHealth. The end and beginning "" are not needed as the "/" will make it seem like a string.

2 answers

✓ Accepted answer

""..humanoid.Health.."/"..humanoid.MaxHealth..""

3 comments

0

That's all I was missing? Thanks a million!

0

Incorrect answer.

0

I would also disagree on using a loop. Loops are ugly unless they're needed.

local player = game.Players.LocalPlayer --replaced as this is better/easier.
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. 
local character = player.Character 
local humanoid = character:WaitForChild("Humanoid") --Changed to WaitForChild as it will wait for Humanoid
local labelText = script.Parent

humanoid.Health.Changed:connect(function() --This is better as it will not run a continous loop and cause lag.
labelText.Text = humanoid.Health.."/"..humanoid.MaxHealth --This was the problem as well, you didn't have the .Text so it wouldn't do anything
end)

--This should be a local script btw, I noticed you use the game.Parent.Parent etc, but you could simply do game.Players.LocalPlayer.

This discussion is preserved as it was. New answers, comments, and votes are closed.