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

Health based off IntValue's?

Asked by
lomo0987 250 Moderation Voter
9 years ago

I have been trying to get help over the past few days.. And nothing has worked.

What I have been trying to do is take the leaderstat 'Health' put it to 100 if it's lower then 100. Then, When ever they respawn, change their health and maxhealth to the IntValue of 'Health' in leaderstat.

player>leaderstat>Health

0
Could you clarify what you want the IntValue to be? GoldenPhysics 474 — 9y
0
I already have the IntValue, and it's Health located within the leaderstat. lomo0987 250 — 9y
0
What do you want it to be set to? GoldenPhysics 474 — 9y
0
I don't need the IntValue changed at all, what I am looking for is a script that takes that IntValue, and sets a persons max health and normal health according to that IntValue within the leaderstat. lomo0987 250 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
wait(0)
plr=game:service("Players").LocalPlayer
repeat wait(0)until plr.Character~=nil --I guess you can remove the nil if you want
plr2=plr.Character:FindFirstChild("Humanoid")
if plr2~=nil then --I guess you can remove the nil if you want
plr2.MaxHealth=plr:FindFirstChild("leaderstats").WHATEVERTHENAMEIS.Value
plr2.Health=plr2.MaxHealth
elseif not plr2~=nil or not plr:FindFirstChild("leaderstats")~=nil or not plr:FindFirstChild("leaderstats"):FindFirstChild("WHATEVERTHENAMEIS")~=nil then
print("Humanoid does not exist")
end
0
Still doesn't work :/ lomo0987 250 — 9y
0
Then I must've scripted it wrong, can you send me a PM with the script your using (The Code) so that I can better understand what you want, please? TheeDeathCaster 2368 — 9y
0
Oh, i might have missed the last part. let me edit that part too :/ lomo0987 250 — 9y
0
Nope, it still doesn't like to do it :/ lomo0987 250 — 9y
Ad
Log in to vote
-2
Answered by 9 years ago

When the Character is added after the character is removed, set Health and MaxHealth to the value.

edit:

local SetHealth = 120

Players.PlayerAdded:connect(plr
    plr.CharacterAdded:connection(Character
        Character.Humanoid.MaxHealth = SetHealth
        Character.Humanoid.Health = SetHealth
    end)
end)

That might not be perfect, but it should be close.

0
You don't know how many times i've tried stuff like that. Nothing like that has worked yet. :/ lomo0987 250 — 9y

Answer this question