Hello!
I am trying to make the Max Health of a player increase as they level up. I've included the entire leaderboard script below, All of it works fine when I remove the Health portion of the script, but I'd really like to get that part functioning too. I've approached it several different ways, generally getting the output that "Health" or "Humanoid" or "plr" is not a valid part of Workspace.
Any advice would be much appreciated!
The problematic part of the script:
local Health = game.Workspace.plr.Health
local MaxHealth = game.Workspace.plr.Health * level.Value + 10
The entire leaderboard script:
game.Players.PlayerAdded:connect(function(plr)
local stats = Instance.new('IntValue', plr)
stats.Name = 'leaderstats'
local points = Instance.new('IntValue', stats)
points.Name = 'Points'
points.Value = 0
local experience = Instance.new('IntValue', stats)
experience.Name = 'EXP'
experience.Value = 0
local level = Instance.new('IntValue', stats)
level.Name = 'Level'
level.Value = 0
-- The two lines below is where it breaks
local Health = game.Workspace.plr.Health
local MaxHealth = game.Workspace.plr.Health * level.Value + 10
-- The two lines above is where it breaks
experience.Changed:connect(function()
local required=(level.Value*70) -- Number reflects the EXP points needed to level up.
if experience.Value >= required then
level.Value=level.Value+1
experience.Value=experience.Value-required
end
end)
end)

3 comments
Thank you for the assistance!! :D Once I changed "player" to "plr" throughout, it all worked just fine! Thank you!
Whoops, sorry about that! Typed it up quick without testing. You're welcome though!
No problem at all good sir! You helped me solve a very nagging problem! Much appreciated! :)