Yo, so my datastore script seems to have this issue where instead of saving the players level and exp, it for some reason jumps a level or two sometimes?? (for example: the players level would be 1, then once they leave and rejoin it becomes 2?)
Here is the code if anyone wants to know;
local DSService = game:GetService("DataStoreService"):GetDataStore("-test#1222")
local RunService = game:GetService("RunService")
game.Players.PlayerAdded:Connect(function(plr)
local uniquekey = 'id-'..plr.userId
local leaderstats = Instance.new("Folder", plr)
local Level = Instance.new("NumberValue")
local EXP = Instance.new("NumberValue")
local MaxEXP = Instance.new("NumberValue")
local Cash = Instance.new("NumberValue")
local FactionEXP = Instance.new("NumberValue")
local Strength = Instance.new("NumberValue")
local Stamina = Instance.new("NumberValue")
local Defence = Instance.new("NumberValue")
local Quirk = Instance.new("NumberValue")
local Points = Instance.new("NumberValue")
local New = Instance.new("BoolValue")
leaderstats.Name = "Data"
Level.Parent = leaderstats
EXP.Parent = leaderstats
MaxEXP.Parent = leaderstats
Cash.Parent = leaderstats
FactionEXP.Parent = leaderstats
New.Parent = leaderstats
Strength.Parent = leaderstats
Stamina.Parent = leaderstats
Defence.Parent = leaderstats
Quirk.Parent = leaderstats
Points.Parent = leaderstats
Level.Name = "Level"
EXP.Name = "EXP"
MaxEXP.Name = "MaxEXP"
Cash.Name = "Cash"
FactionEXP.Name = "FactionEXP"
Strength.Name = "Strength"
Stamina.Name = "Stamina"
Defence.Name = "Defence"
Quirk.Name = "Quirk"
Points.Name = "Points"
New.Name = "New"
Level.Value = 1
EXP.Value = 0
MaxEXP.Value = 100
Cash.Value = 0
FactionEXP.Value = 0
New.Value = true
Strength.Value = 0
Stamina.Value = 0
Defence.Value = 0
Quirk.Value = 0
Points.Value = 0
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
Level.Value = GetSaved[1]
EXP.Value = GetSaved[2]
Cash.Value = GetSaved[3]
FactionEXP.Value = GetSaved[4]
New.Value = GetSaved[5]
Strength.Value = GetSaved[6]
Stamina.Value = GetSaved[7]
Defence.Value = GetSaved[8]
Quirk.Value = GetSaved[9]
EXP.Value = GetSaved[10]
Points.Value = GetSaved[11]
else
local NumberFS = {Level.Value,EXP.Value,Cash.Value,FactionEXP.Value,New.Value,Strength.Value,Defence.Value,Quirk.Value,Stamina.Value,MaxEXP.Value,Points.Value,}
DSService:SetAsync(uniquekey,NumberFS)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local uniquekey = "id-"..plr.userId
local SaveTable = {plr.Data.Level.Value,plr.Data.EXP.Value,plr.Data.Cash.Value,plr.Data.FactionEXP.Value,plr.Data.New.Value,plr.Data.Strength.Value,plr.Data.Defence.Value,plr.Data.Stamina.Value,plr.Data.Quirk.Value,plr.Data.MaxEXP.Value,plr.Data.Points.Value}
DSService:SetAsync(uniquekey, SaveTable)
print("Number")
end)~~~~~~~~~~~~~~~~~

1 comment
Contact me via discord and I might be able to help you in another way Mystifine#4924