Kampfkarren / Roblox

Scripts and stuff I wrote for Roblox. Documentation is little to none as these are just stuff I took from my game that I thought I could share.
https://kampfkarren.github.io/Roblox/
Other
285 stars 78 forks source link

:Set() when player is leaving #139

Closed boeljoet closed 3 years ago

boeljoet commented 3 years ago

i have a couple of folders with content that i want to save. i tryed

players.PlayerRemoving:Connect(function(player)
local PetStore = DataStore2("Pets", player)
...
...
...
PetStore:Set({["PetData"] = PetData, ["PlayerData"] = PlayerData})
end)

and it is not saving

i checked the order in wich datastore2 works. it does run the set command before the save.

tryed the BeforeSave(modifier: (dataValue: any) => any). same issue.

both test are in game (not in studio)

if i test it in studio… it somewhow does works

(i posted this on roblox as well https://devforum.roblox.com/t/datastore2-set-when-player-is-leaving/1364769)

Kampfkarren commented 3 years ago

You're not using DataStore2 correctly. Reread the documentation.

Screenshot_20210721-081650_Chrome

boeljoet commented 3 years ago

in this instance i have no choice. the pet folder is wildly updating, adding and removing pets. and ill have to keep track of all the connections being made and disconnect them to keep the server clean. either that or turn the entire pet system to datastore 2 which is more work.

i was hoping on a quick solution.

thank you for the reply ^^ i do know how to continue tho :D

Kampfkarren commented 3 years ago

the pet folder is wildly updating, adding and removing pets.

Your code updates, adds, and removes pets. Update DataStore2 at the same time you're doing that.