Not running script because past shutdown deadline from shutdown?

I am trying to save the players stats and stuff when I shutdown but I keep getting this error, I don’t want to lose any data. Error is “Not running script because past shutdown deadline from shutdown”

game:BindToClose(function()

		local players = Players:GetPlayers()
		for _, player in pairs(players) do
			player:Kick()
		end
       wait(30)

end)

1 Like

The problem is that the server doesn’t wait for scripts that are currently running, the server just stops them.
Otherwise a lot of servers would be online 24/7 because a script is running.

Read this post, it might help solving the problem.

2 Likes

You have no reason to kick players on BindToClose.

What you should do is ensure that player’s stats are saved in BindToClose, however, if you take too long to save data, Roblox is just going to stop the script (as BindToClose scripts only have ~30 seconds to do stuff)

As buildthomas has said, you should have autosaves and save data on BindToClose as-well as on PlayerRemoving.

1 Like
  1. You don’t need to kick players if it’s closing. By definition they will be removed.
  2. Your wait(30) holds up the server for 30 seconds + margin + the time taken to kick the players. BindToClose can only run for a maximum of 30 seconds so you’re running into the error.

Primarily, get rid of the useless wait. Once you’ve done your business let the function end so the game server can close (you’re unnecessarily holding it open for 30 seconds).

2 Likes