I have tried to make a message when the server is shutdown but it does not seem to work. It is a normal script in workspace.
game.Onclose = function() for _,Player in pairs (GetPlayers()) do Player:Kick("This server has been shutdown by boogieboon. This is probably due to Updates; try rejoining ASAP.") repeat wait() until not Player.Parent end end
game.Onclose
doesn't shut the server down itself, but only executes whatever code it is tasked to execute within a 30 second yielding period. After the code is ran or the yielding period is up, the server then proceeds to shutdown.
Your code snippet would work if you had another function that enforced the shutdown. It wouldn't make much sense, however, because this function essentially does the same thing.
You are now only left with one option, which is creating a function to take care of the shutdown instead of using your current method.
local shutdown = function(message) for _, Player in pairs(game.Players:GetPlayers()) do -- loop through players Player:Kick(tostring(message)) -- kick, with message being the supplied argument end end shutdown("shutdown message") -- "shutdown message" will be displayed whenever the --players get kicked.
Note:you need to find a more practical way of using this concept, because as of now it will initiate the call to shutdown the server as soon as it is created.
Nothing is really wrong, but the repeat is unneeded, and you did GetPlayers()
as if there was a function.
Try this...
game.OnClose = function() for _,v in pairs(game.Players:GetPlayers()) do v:Kick("This server has been shutdown by boogieboon. This is probably due to Updates; try rejoining ASAP." end end