I've been trying to code it so that I can have a level up system on this game I'm developing, but it's not working. I need some help. Here's my code:
game.Players.PlayersAdded:connect(function(plr) local stats = Instance.new('IntValue', plr) stats.Name = 'leaderstats' local experience = Instance.new('IntValue', stats) experience.Name = 'EXP' experience.value = 0 local level = Instance.new('IntValue', stats) level.Name = 'Level' level.Value = 0
experience.Changed:connect(function() level.Value = math.floor(experience.Value / 1000) end)
end)
And
local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild('leaderstats') local level = leaderstats:WaitForChild('Level') local xp = player:WaitForChild('EXP')
level.Changed:connect(function() if xp.Value < 1000 then level.Value = 1 end end)