I’m making a script that uses DS2 to save data. I’m creating a fake player to save the data on as a “custom-key”.
Due to it not being a real player, the DS2 does not fire :Save() on it, so I’ve made my own methods.
I’ve decided to use :BindToClose(), so that when the server is shutting, the data saves.
Here are my two save functions. I’m testing in studio. All other saves are done on the change of the value, no need for PlayerRemoving.
while wait(60) do
local FakePerson = {UserId = 851048880, AncestryChanged = Instance.new("BindableEvent").Event, ClassName = "Player"}
local GARCoinStoreVault = DataStore2("GlobalBankAmounts", FakePerson)
GARCoinStoreVault:Save()
end
game:BindToClose(function()
local FakePerson = {UserId = 851048880, AncestryChanged = Instance.new("BindableEvent").Event, ClassName = "Player"}
local GARCoinStoreVault = DataStore2("GlobalBankAmounts", FakePerson)
GARCoinStoreVault:Save():Wait()
end)
However, once I leave the testing, and rejoin, the data does not save… Need some help.
Edit: I tested with and without the :Wait() after save. Both didn’t work.