I need help. I want to shutdown a game but I want a custom message. e.g. This game has shutdown because it has been updated. I want this on the red bar on top that normally appears when you Lost Connection.
Any tips or tricks? Thanks!
I need help. I want to shutdown a game but I want a custom message. e.g. This game has shutdown because it has been updated. I want this on the red bar on top that normally appears when you Lost Connection.
Any tips or tricks? Thanks!
Using a for loop on the Players service kicking each individual player with the Kick method should do the trick. The Kick method has an optional argument that should be passed as a string value, that displays a kick message in that red bar when the game shuts down. Here would be an example:
local Players = game:GetService("Players")
local ShutdownMessage = "The game has been updated"
local function Shutdown()
local Players = Players:GetPlayers()
for i = 1,#Players do
local Player = Players[i]
Player:Kick(ShutdownMessage) -- Passing "The game has been updated" as the shutdown message
end
end
delay(60*5,Shutdown) -- Make the game shutdown after 5 minutes
Hope this helped. If you have any questions, just let me know. Here's some more information on the Kick method: http://wiki.roblox.com/index.php?title=API:Class/Player/Kick
"" test ""
I don't think you can do this for shutdown itself, but you could hook up to game:OnClose callback and kick all playersanually, since you can display message then.
function game:OnClose()
for n, obj in ipairs(game.Players:GetPlayers()) do
obj:Kick("Updating game")
end
end
If there is nicer way, please correct me.
OnClose isn't a method :p
Doesn't matter, would be worse if it was the other way around.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I can't find anything on roblox wiki related to this. So if you find a link. Tell me.