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

How to acsess a local palyers humanoid to display his health in a gui?

So i couldent find a tutorial on this I want to make a gui that says health:100 but i have no idea how to acces a local players humanoid

1 answer

✓ Accepted answer

Here's how to access the players humanoid's health:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")

function onHealthChanged(newHealth)
	--Do whatever you want with the newHealth here
end

player.CharacterAdded:Connect(function(char)
	local character = char
	local humanoid = char:WaitForChild("Humanoid")
	healthChanged:Disconnect()
	healthChanged = humanoid.HealthChanged:Connect(onHealthChanged)
end)

local healthChanged = humanoid.HealthChanged:Connect(onHealthChanged)

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