I have a script and the problem is that a player leaves before it finishes saving and so everything is returned nil because it can't find the player. I used BindToClose which I'm pretty sure is keeping the server from shutting down while saving, my plr variable are returning nil because the player has left already. Can someone point me in the right direction. Thx in Advance.
COMMUNITY QUESTION
How to stop player from leaving before save occurs?
1 answer
Since no content was provided, I'll provide you with a simple fix.
game.Players.PlayerRemoving:Connect(function(Player)
-- Save Data here
end)
This event is fired when the player leaves. Just save data when they leave, this should fix your problem.
Hopefully this helped!
Best of luck developer!
BlackOrange3343
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
no code?
No reason for code. i just need to know a method or module for doing this
Are you... unsatisfied. lol
yes
use a PlayerRemoving event. It will save before the player leaves.
Be back 2:50 CST
I've been using PlayerRemoving
DataModel BindToClose https://developer.roblox.com/api-reference/function/DataModel/BindToClose