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

How do I make a script so my health adjusts to my Level?

Asked by 4 years ago

For example, if I'm level 10, my max health of 100 goes to 300, basically increasing +20 max health everytime my leaderstats level increases?

I have tried something like this, but I realized it's not working because its a local script (and doesn't work on filtering enabled functions)

repeat
    wait()
until game.Players.LocalPlayer:findFirstChild("leaderstats") and game.Players.LocalPlayer:findFirstChild("Level", true)
local Ammount = 25
while true do
    wait()
    if game.Players.LocalPlayer.Character.Humanoid.MaxHealth < game.Players.LocalPlayer.leaderstats.Level.Value * Ammount + 100 then
        game.Players.LocalPlayer.Character.Humanoid.MaxHealth = game.Players.LocalPlayer.leaderstats.Level.Value * Ammount + 100
        game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.leaderstats.Level.Value * Ammount + 100
    end
end 

2 answers

Log in to vote
0
Answered by 4 years ago

I solved it, thanks!

game.Players.PlayerAdded:connect(function(plr))
    repeat wait() 
    until plr:findFirstChild("leaderstats") and plr:findFirstChild("Level", true)
        local Ammount = 25
        while true do
        wait()
        if plr.Character.Humanoid.MaxHealth < plr.leaderstats.Level.Value * Ammount + 100 then
            plr.Character.Humanoid.MaxHealth = plr.leaderstats.Level.Value * Ammount + 100
            plr.Character.Humanoid.Health = plr.leaderstats.Level.Value * Ammount + 100
        end
    end
end)
Ad
Log in to vote
0
Answered by 4 years ago

Try this. Just please remember I suck at Lua.

Multiplication = 1
while true do
    if Level = Multiplication * 10 then
    game.Players.LocalPlayer.Character.Humanoid.MaxHealth = game.Players.LocalPlayer.Character.Humanoid.MaxHealth + 200
    game.Players.LocalPlayer.Character.Humanoid.Health = game.Players.LocalPlayer.Character.Humanoid.Health + 200
    wait()
    end
end

Answer this question