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

Health based off IntValue's?

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

4 comments

0

Could you clarify what you want the IntValue to be?

0

I already have the IntValue, and it's Health located within the leaderstat.

0

What do you want it to be set to?

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.

2 answers

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

4 comments

0

Still doesn't work :/

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?

0

Oh, i might have missed the last part. let me edit that part too :/

0

Nope, it still doesn't like to do it :/

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.

1 comment

0

You don't know how many times i've tried stuff like that. Nothing like that has worked yet. :/

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