Okay, so basically I have a building save system and it needs to run code after a player leaves, but I am wondering that does a server end and delete itself after the last person leaves?
Or does it finish running any code still executing and then stops itself? Thank you.
I believe so, if you want to make it so it saves when a server is shutting down after the last player leaving or when the server shuts down, BindToClose is what you need
I’m currently using PlayerRemoving, does that execute code before the server ends when the player leaves? I tried it on server and it does. So is it okay if I just use that?
You could, but it’s better to be safe than sorry by also using BindToClose the event you shut down your game or if in some cases the last palyer leaving wont have their builds saved before the server shuts down
So should I replace PlayerRemoving with BindToClose or does BindToClose only execute when the server is about to close? If that’s the case, I will keep PlayerRemoving. Thanks.
No no I meant, use both PlayerRemoving AND BindToClose. So it saves for when a palyer leaves and when the Seerver shuts down, that way you can account for every scenario
When the last player leaves and when you shutdown the servers. You’ll have to treat BindToClose as a save everyone’s data, as @JackscarIitt mentioned. It does run whe nthe last palyer leaves, but also when you shutdown a specific server/all the servers
Also BindToClose doesn’t execute code in server while testing in Studio, or it doesn’t show up in the output. Is this normal because the server still exists in your window, and the code still executes but you just can’t see the output because the server is gone?
Does anyone know how I can see BindToClose() output after shutting down my server window in Test Mode? I think the only way to stop the server is by pressing the “X” button, therefore deleting output. Thanks.