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

How do you make it so that the player's max health is increased each time he levels up?

How do you make it so that the player's max health is increased each time he levels up? Thanks!

local leaderstats = Instance.new("IntValue")
local lv = Instance.new("IntValue",leaderstats)
local exp = Instance.new("IntValue",leaderstats)
local levelUp = {32, 64, 128, 256, 512, 1024, 2048}

game.Players.PlayerAdded:connect(function(Player)
	lv.Name = "Lv"
	lv.Value = 1
	exp.Name = "EXP"
	exp.Value = 0
	leaderstats.Parent = Player
	leaderstats.Name = "leaderstats"
	exp.Changed:connect(function()
		if exp.Value >= levelUp[lv.Value]then
			exp.Value = exp.Value - levelUp[lv.Value]
			lv.Value = lv.Value + 1
			Player.Character.Humanoid.MaxHealth = Player.Character.MaxHealth + 100 -- I tried this
        end
    end)
end)

3 comments

0

You forgot humanoid on line 17 after the =.

1

You forgot humanoid on line 17 after the =.

1

Also, the player's MaxHealth resets to 100 when they die... Find a way to make it so the MaxHealth remains the same after they respawn (hint hint: CharacterAdded())

1 answer

✓ Accepted answer

Do something like Multiply the Max health by the level that would work or if you want it less you could multiply the maxhealth by the level divided by 1.5

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