Now this script only runs once, which is why the health isn't going up. To fix this, I would recommend adding a .Changed event that checks for any changes on the lvl value.
I would also recommend doing this on a server script, preferably the script that handles creating the leaderstats.
in a server script:
game.Players.PlayerAdded:Connect(function(Player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = Player
local lvl = Instance.new("IntValue")
lvl.Name = "Lvl"
lvl.Parent = stats
lvl.Changed:Connect(function()
local char = Player.Character or Player.CharacterAdded:wait()
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.MaxHealth = 100 + (lvl.Value * 10)
Humanoid.Health = Humanoid.MaxHealth
end)
end)
This script checks for any property change in "lvl" and if there is, adds to the the humanoid's maxhealth.
I hope this helps.
2 comments
You want to be doing this on the server with a changed event for lvl
i have lvl as a leaderstat