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

Return and save the number of a humanoid's health property?

Asked by 5 years ago

I'm looking to save the current value of a target's health as a variable, but I don't want that variable to update as his health regenerates or changes. I'm still pretty new to scripting, but is there any way I can save a targets health as a static number that will not change?

0
local Health = Humanoid.Health, variables don't update on their own. INOOBE_YT 387 — 5y
0
^ RAYAN1565 691 — 5y

1 answer

Log in to vote
0
Answered by
F_F 53
5 years ago

Yes, here is an example :

local Humanoid = Target:WaitForChild("Humanoid") -- Target being the model that the humanoid is located in

local HealthVariable


Humanoid.HealthChanged:Connect(function(currentHealth)
       HealthVariable = currentHealth
end)

and if you want to have it saved forever I recommend looking into DataStore

Ad

Answer this question