RequestShutdown (Callback)
From Legacy Roblox Wiki
(Redirected from RequestShutdown)
RequestShutdown | |
Parameters: | nil |
Returns: | bool |
Description: | When LocalSaveEnabled is true, this is invoked when an attempt to shutdown the game is made. This member requires elevated permissions to be used. |
Member of: | DataModel |
Remarks
This callback is used internally, working with Roblox's game HUD. When you try to leave a place that has been opened in build mode, RequestShutdown is invoked, which causes a custom GUI prompt to pop up, asking if you want to save your place.
When the callback function returns false, a legacy save prompt will pop up. If true is returned, nothing happens, allowing a custom save prompt to be used.
Example
The following code would prevent any formal attempt of shutting down the game from working. Remember that elevated permissions are required.
game.RequestShutdown = function()
print("A feeble attempt to shutdown the game was made.")
return true
end
The following is an excerpt from Roblox's SettingsScript, which uses RequestShutdown to create a GUI save prompt.
--Spawn a thread for the Save dialogs
local isSaveDialogSupported = pcall(function() local var = game.LocalSaveEnabled end)
if isSaveDialogSupported then
delay(0,
function()
local saveDialogs = createSaveDialogs()
saveDialogs.Parent = gui
game.RequestShutdown = function()
table.insert(centerDialogs,saveDialogs)
game.GuiService:AddCenterDialog(saveDialogs, Enum.CenterDialogType.QuitDialog,
--ShowFunction
function()
saveDialogs.Visible = true
end,
--HideFunction
function()
saveDialogs.Visible = false
end)
return true
end
end)
end