Skip to content

Commit

Permalink
Fix BindToClose extending too long if :Save() resolves immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampfkarren committed Sep 4, 2019
1 parent ea50084 commit 691b916
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions DataStore2/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
coinStore:Get()
--]]

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ServerStorage = game:GetService("ServerStorage")

Expand Down Expand Up @@ -574,7 +575,9 @@ end
function DataStore2.SaveAll(player)
if DataStoreCache[player] then
for _, dataStore in pairs(DataStoreCache[player]) do
dataStore:Save()
if dataStore.combinedStore == nil then
dataStore:Save()
end
end
end
end
Expand Down Expand Up @@ -645,7 +648,10 @@ function DataStore2.__call(_, dataStoreName, player)

game:BindToClose(function()
if not fired then
player.Parent = nil -- Forces AncestryChanged to fire and save the data
spawn(function()
player.Parent = nil -- Forces AncestryChanged to fire and save the data
end)

event.Event:wait()
end

Expand Down

0 comments on commit 691b916

Please sign in to comment.