Okay so I tried making a level system, everything works apart from leveling up, I have tried to give myself "50" XP (That is how much is required to level up) my XP goes to 50 but my level does not seem to want to change to level 2.. I am not getting anything in the output box. Can someone help me please? I have been trying to fix this problem for so long now!
Here is the level up system code!
local DataStore = game:GetService("DataStoreService") local lvl = DataStore:GetDataStore("LevelSaveSystem") game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Folder",player) leaderstats.Name = "leaderstats" local Level = Instance.new("IntValue",leaderstats) Level.Name = "Level" Level.Value = lvl:GetAsync(player.UserId) or 1 Level.Changed:connect(function() lvl:SetAsync(player.UserId, Level.Value) end) if (Level.Value > 100) then -- MaxLevel Level.Value = 100 end local DataStore = game:GetService("DataStoreService") local xp = DataStore:GetDataStore("XPSaveSystem") local XP = Instance.new("IntValue",leaderstats) XP.Name = "XP" XP.Value = xp:GetAsync(player.UserId) or 0 xp:SetAsync(player.UserId, XP.Value) XP.Changed:connect(function() xp:SetAsync(player.UserId, XP.Value) end) XP.Changed:connect(function()XPChange(player,XP,Level) end) end) function XPChange(player,XP,Level) if XP.Value >= Level.Value*50 then -- Takes 50 XP to get to Level 2 then 100 XP to get to Level 3 etc... also If you level up then... XP.Value = 0 Level.Value = Level.Value+1 end end game.Players.PlayerRemoving:connect(function(player) lvl:SetAsync(player.UserId, player.leaderstats.Level.Value) DataStore:GetDataStore("XPSaveSystem"):SetAsync(player.UserId, player.leaderstats.XP.Value) end)
I'm not sure, but have you tried giving yourself more than 50 XP?