Hello, so recently I did a soft release for my game to gain a small player base just to make sure I have no bugs and to get some more ideas. In the game, people are gaining head-muscle and leveling up. The table for these stats looks like this
local DEFAULT_STATS_TABLE = {
Level = 1,
HeadScale = 0.01,
Rebirth = 0,
totalClicks = 0,
PlrHammer = "BasicHammer",
headIncAmount = 0.05
}
This table is located at the top of the module script like this
local dataLib = {}
--Datastore2 Combine
local CURRENT_SESSION = {}
local USED_CODES = {}
local DEFAULT_STATS_TABLE = {
Level = 1,
HeadScale = 0.01,
Rebirth = 0,
totalClicks = 0,
PlrHammer = "BasicHammer",
headIncAmount = 0.05
}
--all of the other stuff
return dataLib
I have recently discovered that when a new player joins, their data does not get set to “DEFAULT_STATS_TABLE” anymore, for some reason they begin setting to other player’s stats; usually a common player. For instance when I first joined with another account to test this(A brand new account)

This will obviously be a huge problem and although I would rather not reset data because some players actually grinded from level 1, I may have to and I am willing to if it means fixing this. I believe it is happening somewhere within my data module so these are a few of the functions being run that I think are causing this. This one is when the player first joins
game.Players.PlayerAdded:Connect(function(playerJoined)
local playerStatsData = DataStore2("PlayerStatsDataV13", playerJoined)
local usedCodesData = DataStore2("PlayerUsedCodesV7", playerJoined)
local success, data = pcall(function()
return playerStatsData:Get()
end)
if success then --Get Player Stats Data
if data then
CURRENT_SESSION[playerJoined] = data
loadPlayerStats(playerJoined)
else
--New player has joined
CURRENT_SESSION[playerJoined] = DEFAULT_STATS_TABLE
playerStatsData:Set(CURRENT_SESSION[playerJoined])
loadPlayerStats(playerJoined)
end
else
print(data.." ERROR")
end
local successb, datab = pcall(function()
return usedCodesData:Get()
end)
if successb then
if datab then
USED_CODES[playerJoined] = datab
else
USED_CODES[playerJoined] = {}
usedCodesData:Set(USED_CODES[playerJoined])
end
else
print(datab.." ERROR")
end
end)
I really haven’t changed anything here because I just can’t see the problem.
This is the function I use to save the data
local function SAVE_DATA(player)
if CURRENT_SESSION[player] then
local playerData = DataStore2("PlayerStatsDataV13", player)
playerData:Update(function(old)
return CURRENT_SESSION[player]
end)
local playerData = DataStore2("PlayerUsedCodesV7", player)
playerData:Update(function(old)
return USED_CODES[player]
end)
end
end
All of these are begin saved in a local session table that holds everyone’s data by name.
local CURRENT_SESSION = {}
local USED_CODES = {}
Thank you for your help in advance!