The game I am currently making has levels that increase health as you level up. How do I make it so that the player spawns with the max health instead of 100? Any help would welcome! Script im adding it too:
game.Players.PlayerAdded:connect(function(Player)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "Leaderstats"
local Level = Instance.new("IntValue", Leaderstats)
Level.Name = "LevelLable"
Level.Value = 1
local Exp = Instance.new("IntValue", Leaderstats)
Exp.Name = "ExpLable"
Exp.Value = 0
if Player.Character and Player.Character:FindFirstChild("Humanoid") then
Player.Character.Humanoid.MaxHealth = 90 + Level.Value*10
end
Level.Changed:connect(function(value)
if Player.Character and Player.Character:FindFirstChild("Humanoid") then
Player.Character.Humanoid.MaxHealth = 90 + Level.Value*10
end
end)
Player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").MaxHealth = 90 + Level.Value*10
end)
end)

2 comments
Edit this post and format your code by clicking on the blue Lua icon which will insert two lines of "~~~~". Place the code in between these two lines. Makes it easier for us to read.
Sorry, my first time using this site!