This whole process should be done under game.Players.PlayerAdded
.
All you have to do is use DataStoreName:RemoveAsync(Key)
for each of the 13 data stores.
This whole process should be done under game.Players.PlayerAdded
.
All you have to do is use DataStoreName:RemoveAsync(Key)
for each of the 13 data stores.
How about when the player leaves the game? How can I save the stats from table in the new datastore?
local data = {}
for _, stat in pairs(player.leaderstats:GetChildren())do
data[stat.Name] = stat.Value
end
local success, err = pcall(function()
dataStore:SetAsync(player.UserId, data)
end)
No, don’t worry about it, I posted a reply in the wrong thread so I deleted it but it doesn’t get removed straight away - that’s what you saw.
The player’s has left before the first data is saved meaning Player=nil.
I already did what they suggested above, saved the old datastore to a single data store using an empty table but how to prevent what you have said?
Store the player’s user id as a variable before you save
local userId = Player.UserId
Then use this variable instead of Player.UserId when saving.