Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Number value = health?[NOT ANSWERED]

Asked by 10 years ago
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?

0
You have to loop it to constantly give you the current health number. Orlando777 315 — 10y
0
so i would have to do like for i = 1,1000 do? and then paste line 6 in there? kingalpha1 15 — 10y

1 answer

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

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)
Ad

Answer this question