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

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

Asked by 8 years ago

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)
0
You forgot humanoid on line 17 after the =. GoldenPhysics 474 — 8y
1
You forgot humanoid on line 17 after the =. GoldenPhysics 474 — 8y
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()) Discern 1007 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

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

Ad

Answer this question