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

Number value = health?[NOT ANSWERED]

Player = script.Parent.Parent.Parent.Parent.Parent

if Player:FindFirstChild("Health") == nil then
	Health = script.Health:Clone()
	Health.Parent = Player
	Health.Value = Player.Character.Humanoid.Health.Value
	end
script.Parent.Main.Disabled = false

Is there a way for me to make the number value[Health] = to the players actual health no matter what it is?

2 comments

0

You have to loop it to constantly give you the current health number.

0

so i would have to do like for i = 1,1000 do? and then paste line 6 in there?

1 answer

Add a changed function, so whenever the Humanoid's health is changed, it will update to the number value.

Player = script.Parent.Parent.Parent.Parent.Parent
HealthValue = Instance.new("NumberValue", Player)
HealthValue.Name = "Health"
HealthValue.Value = Player.Character.Humanoid.Health.Value

function HealthOnChange()
	local Health = Player:WaitForChild("Health")
	local Humanoid = Player.Character.Humanoid
	Health.Value = Humanoid.Health
end

script.Parent.Main.Disabled = false

Player.Humanoid.Changed:connect(HealthOnChange)

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