|
| 18 Feb 2017 02:21 PM |
So could I use it like this? There's precious little info on the wiki, sorry.
function save() --Save data end
game:BindToClose(save)
--Then, can I just call the function like normal?
game.Players.PlayerRemoving:connect(function() save() end) |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:23 PM |
| I'd just loop through the players and save all the Data, as this holds the game from closing but it will close. So go through and save all the data then wait() to close the game, as it will allow for it to correctly save. |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:26 PM |
PlayerRemoving is called after the player's already left. BindToClose is called when the player clicks the X button.
essentially, PlayerRemoving is for the client, and BindToClose is for the server. Since you're calling both you're saving the data twice.
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:26 PM |
Er, reverse my last post. PlayerRemoving is for the Server and BindToClose is for the Client.
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:29 PM |
| I'm 99% sure BindToClose() is a function that binds a function to run, and ### game does not close until that function is done. PlayerRemoving() is fired when a player leaves ### game. Thanks for ### help anyway. |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:31 PM |
Yes, you're correct. But if you're calling save() in both function...
First, the player closes the game, which triggers BindToClose and runs save().
Then, the server gets notified that the player is leaving and starts PlayerRemoving(). Since you've bound save to PlayerRemoving, save() is run a second time and the data is saved again, possibly incompletely.
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:33 PM |
@mister1nothing
What are you even talking about? BindToClose is when the server shuts down, playerleaving is when a player leaves.
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:35 PM |
| So then what should I do to just make it so ### game doesn't shut down until their data saves? Add this to ### script that saves?: game:BindToClose:connect(function() wait(30) end) |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:35 PM |
| Roblox loves filtering "the". |
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:37 PM |
void BindToClose ( function function )
it takes in a function
so yes you can do that
|
|
|
| Report Abuse |
|
|
|
| 18 Feb 2017 02:38 PM |
| Um. What? Yeah ### filter's a little overbearing. Anyway, I was mistaken, I thought BindToClose was a clientside function. Rereading ### devforum I see it's a server-side function now. It'd be easier to just do game.BindToClose(function(save() wait(30)); |
|
|
| Report Abuse |
|
|
| |
|