basically whenever two people join the game at the same time (only when its at the same time) they will both have the same data picked from one of the two users rather than individual users
local returned, returneddata = pcall(function()
local datastore = game:GetService("DataStoreService")
local cashdata = datastore:GetDataStore("cash3-datastore-string")
local currentbackpackdata = datastore:GetDataStore("currentbackpackstorage4-datastore-string")
local ownedbackpackdata = datastore:GetDataStore("backpackowned4-datastore-string")
local ownedbackpackstoragedata = datastore:GetDataStore("backpackownedstorage4-datastore-string")
local currenttooldata = datastore:GetDataStore("currentownedtool5-datastore-string")
local rebirthsdata = datastore:GetDataStore("rebirthsdata5-datastore-string")
game.Players.PlayerAdded:Connect(function(player)
local Data = Instance.new("Folder",player)
Data.Name = "leaderstats"
local cash = Instance.new("IntValue",Data)
cash.Name = "Gold"
cash.Value = cashdata:GetAsync(player.UserId) or 0
local nonleaderstats = Instance.new("Folder",player)
nonleaderstats.Name = "nonleaderstats"
local currentbackpack = Instance.new("IntValue",nonleaderstats)
currentbackpack.Name = "CurrentBackpack"
currentbackpack.Value = currentbackpackdata:GetAsync(player.UserId) or 0
local ownedbackpack = Instance.new("StringValue",nonleaderstats)
ownedbackpack.Name = "OwnedBackpack"
ownedbackpack.Value = ownedbackpackdata:GetAsync(player.UserId) or "Default"
local ownedbackpackstorage = Instance.new("IntValue",nonleaderstats)
ownedbackpackstorage.Name = "OwnedBackpackStorage"
ownedbackpackstorage.Value = ownedbackpackstoragedata:GetAsync(player.UserId) or 25
local currenttool = Instance.new("StringValue",nonleaderstats)
currenttool.Name = "CurrentTool"
currenttool.Value = currenttooldata:GetAsync(player.UserId) or "Gold Nugget"
local rebirths = Instance.new("IntValue", Data)
rebirths.Name = "Rebirths"
rebirths.Value = rebirthsdata:GetAsync(player.UserId) or 0
game.Players.PlayerRemoving:Connect(function(player)
cashdata:SetAsync(player.UserId, cash.Value)
currentbackpackdata:SetAsync(player.UserId, currentbackpack.Value)
ownedbackpackdata:SetAsync(player.UserId, ownedbackpack.Value)
ownedbackpackstoragedata:SetAsync(player.UserId, ownedbackpackstorage.Value)
currenttooldata:SetAsync(player.UserId, currenttool.Value)
rebirthsdata:SetAsync(player.UserId, rebirths.Value)
end)
while wait(120) do -- Auto Save
cashdata:SetAsync(player.UserId, cash.Value)
currentbackpackdata:SetAsync(player.UserId, currentbackpack.Value)
ownedbackpackdata:SetAsync(player.UserId, ownedbackpack.Value)
ownedbackpackstoragedata:SetAsync(player.UserId, ownedbackpackstorage.Value)
currenttooldata:SetAsync(player.UserId, currenttool.Value)
rebirthsdata:SetAsync(player.UserId, rebirths.Value)
end
end)
end)
print(returned, returneddata)

1 comment
I honestly don't see any reason why it would be mixing up the data since you are using unique UserId keys. The only advise I would give is to use UpdateAsync instead of SetAsync for data you already know has been made. And to combine all your Datastores into one.