Hello, I’ve followed This Tutorial for my datastore but I’m having a big problem. Only the first player who joins the game sees his data load, all the others are then on hold because of sessionlocking when they shouldn’t be. I’m lost and can’t figure out why this is happening. I’ll try to put the parts of the script below, readable, so you can understand my problem. Thank you very much.
So first there is the default data in case there is no data, you can see SessionLock is false
local default = {
SessionLock = false,
CoinsExemple = 0,
}
Then player join :
local function setUp(plr)
local Coins = Instance.new('NumberValue')
Coins.Name = 'Coins'
Coins.Parent = plr
local success, data, shouldWait
repeat
waitForRequestBudget()
success = pcall(dataStore.UpdateAsync, dataStore, key, function(oldData)
oldData = oldData or default
if oldData.SessionLock and not RunService:IsStudio() then
if os.time() - oldData.SessionLock < 1800 then --PROBLEME HERE, second player has sessionlock
shouldWait = true
else
oldData.SessionLock = os.time()
data = oldData
return data
end
else
oldData.SessionLock = os.time()
data = oldData
return data
end
end)
if shouldWait then
task.wait(5)
shouldWait = false
end
until (success and data) or not Players:FindFirstChild(name)
end
--Then i load the value if success and data
Players.PlayerAdded:Connect(setUp)