So basically I have a basic leaderboard script with Level being in game.Players.LocalPlayer.leaderstats.Level
, and I want to change their health based on level (level * 100).
Here's the code I have so far, but I am unsure of where to put it:
game.Players.LocalPlayer.Character.Humanoid.MaxHealth = game.Players.LocalPlayer.leaderstats.Level.Value * 100
To do this you should use the Changed event. This event fires whenever the specified object's value changes.
You can use this event with the player's Level stat, then set their health accordingly.
local plr = game.Players.LocalPlayer; local stats = plr:WaitForChild("leaderstats"); stats.Level.Changed:connect(function(change) local hum = plr.Character:FindFirstChild("Humanoid"); hum.MaxHealth = change*100; --Change health hum.Health = change*100; end)