You probably have seen something like this before, essentially i'm trying to kick the players before the server shuts down. The problem is it doesnt kick the player, and it prints "???" when it should kick me BEFORE printing that. Anyone have any ideas why this wont work???
game:BindToClose(function()
for i, player in ipairs(game.Players:GetChildren()) do
player:Kick("The Game Is Shutting Down, Please Rejoin")
end
print("???")
wait(5)
end)

3 comments
Just a side note you should be using GetPlayers and not GetChildren. However the BindToClose method is called when the server shuts down, usually when the last player in a server leaves, maybe that's why it didn't kick.
it prints "???" and then waits 5 seconds before the server shuts down though
Can you suggest an alternative script because its clear this one doesn't work