BindToClose (and TeleportService?) not functioning properly


In the past, we have been able to use TeleportService in conjunction with BindToClose to teleport our players to a reserved server lobby while we perform game updates (such as with Merely’s soft shutdown script), which allows us to keep the vast majority of our concurrent players after we shutdown our games for updates.

As of yesterday (or the day before?) it instead instantly shuts down the server, preventing us from teleporting any players. It may even be entirely an issue with BindToClose as it doesn’t seem to yield and show the initial warning message that it usually does.

This functionality is super important to a lot of games and I’d hate to lose it!

A full server suddenly loses connection

I’ve been having problems with this as well recently, I thought I made a script error or something while working with datastores but now I am not even sure. If it doesn’t yield then that explains why sometimes data doesn’t save while shutting down the server.


I have also been having issues with BindToClose. In PlaySolo it no longer yields for DataStores and requires me to put a manual wait time at the end of BindToClose to ensure it does actually perform saving etc.


Thank you for bringing this to our attention! We made a change in “Shut Down All Servers” that (unintentionally) disconnected all users from the game before BindToClose callbacks were being invoked. We just disabled that change and will fix the underlying issue before re-enabling.

@wravager this fix likely won’t affect the issue you are seeing in studio, we will follow up with your issue.


Can you please post a minimal code snippet demonstrating the problem?

  • here’s the code.
  • here’s what I expect to happen.
  • here’s what actually happens.


#6 = function(userId)
     do datastore saving here

	for i,v in pairs(data)do

In PlaySolo BindToClose requires this to complete the saving which doesn’t make sense to me.

	for i,v in pairs(data)do


Could I request an even more specific example?
In the code provided, “data” isn’t declared, and “do datastore saving” isn’t really code.
I was hoping for a script I could just run as-is to demonstrate the problem.
The datastore saving could be “dummy” data, just writing out random strings or whatever.

local data 		= {}
local server 	= {}

local service	= game:GetService('DataStoreService')
local store		= service:GetDataStore('data')
local http		= game:GetService('HttpService') = function(userId)
		local userdata = http:JSONEncode(data[userId])
		local success, failure = pcall(function()
			store:SetAsync(userId, userdata)

	data[player.userId] = {}

	for i, v in pairs(data)do



We tried that code on a production build and did not experience the problem you’re describing.

Can you confirm you are seeing this with latest production build (345)?


Merely’s soft shutdown is working again, so I think it is fixed.