Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to stop player from leaving before save occurs?

Asked by
sheepposu 561 Moderation Voter
5 years ago

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.

0
no code? hellmatic 1523 — 5y
0
No reason for code. i just need to know a method or module for doing this sheepposu 561 — 5y
0
Are you... unsatisfied. lol sheepposu 561 — 5y
0
yes hellmatic 1523 — 5y
View all comments (4 more)
0
use a PlayerRemoving event. It will save before the player leaves. namespace25 594 — 5y
0
Be back 2:50 CST sheepposu 561 — 5y
0
I've been using PlayerRemoving sheepposu 561 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

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

Ad

Answer this question