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

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

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

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)

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

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