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

Health number gui?

Hey i try to make a Gui that says youre current health example : Current Health: 50

Here is my code that is in the Textlabel

game.Players.PlayerAdded:connect(function(player)
	local np = player.Humanoid.Health
	script.Parent.Text = np
end)

1 answer

✓ Accepted answer

Okay so, you cannot have a PlayerAdded inside a localscript, and you cannot call the health value in a variable. Use a localscript, and put the following lines:

local player = game.Players.LocalPlayer
repeat wait() until player.Character  -- we wait until player has loaded
local character = player.Character
local hum = character:WaitForChild('Humanoid') -- cant call the 'Health', it has to be called in the script, and wait for humanoid to load
script.Parent.Text = 'Current Health: ' .. hum.Health -- we print the humanoid's health, and use double dots to connect the variable with text

1 comment

0

Thx dude youre a legend

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