This is the script :
game.Players.PlayerAdded:connect(function(Player) local Data = Instance.new("IntValue",Player) Data.Name = "Data" local XP = Instance.new("IntValue",Data) XP.Name = "XP" XP.Value = 0 local Level = Instance.new("IntValue",Data) Level.Name = "Level" ------- It's name is Level Level.Value = 1 XP.Changed:connect(function() XPChange(Player,XP,Level) end) end) function XPChange(Player,XP,Level) if XP.Value >= Level.Value*150 then XP.Value = 0 Level.Value = Level.Value+ 1 end if Level.Value == 100 and XP.Value ==15000 then --How do i make it so if the XP is 15000 they can't level up if they reach the maxXP end end
Just make sure to only do a level change not only if the player's XP is greater than/equal to the Level*150, but also if the level is less than 150. Also it is preferable if you make Data a folder and not an intValue.
game.Players.PlayerAdded:Connect(function(Player) local Data = Instance.new('Folder') Data.Name = 'Data' Data.Parent = Player local XP = Instance.new('IntValue') XP.Name = 'XP' XP.Value = 0 XP.Parent = Data local Level = Instance.new('IntValue') Level.Name = 'Level' Level.Value = 1 Level.Parent = Data XP.Changed:Connect(function() if XP.Value >= Level.Value * 150 and Level.Value < 150 then XP.Value = 0 Level.Value = Level.Value + 1 end end) end)