BindToClose not functioning properly

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to teleport all players to a new server after the current one is shutdown.

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have looked at code from my older project (where it did work) and it looks the same.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

game:BindToClose(function()
	game.ReplicatedStorage.Bricks.Remotes.Misc.ShutdownScreen:FireAllClients()
	local holdingid = require(game.ReplicatedFirst.Place).HoldingId --this is a valid place id
	game:GetService("TeleportService"):TeleportPartyAsync(holdingid, game.Players:GetPlayers(), {}, game.ReplicatedStorage.Misc.HoldingGUI)
	repeat task.wait(0.1) until #game.Players:GetPlayers() == 0
	print("Byee!!!") --this doesn't print when I'm kicked
	task.wait(2)
end)

That’s a good question. The server supposedly waits 30 seconds before actually closing if BindToClose is called, so if any actions take longer than 30 seconds, it should stop those. This doesn’t seem to be the issue here. Maybe try migrating servers instead? I assume shutting down just entirely shuts down, but I’m definitely confused as to why this isn’t working.