queue_on_teleport
Queues a script to execute automatically after a teleport.
function queue_on_teleport(code: string): ()Synopsis
How it works
Registers a Luau source code string to be automatically executed after the player teleports to another place. The code is stored in the executor’s internal queue and compiled+executed once the new place’s DataModelDataModelThe root Instance in Roblox's object hierarchy (game). Contains all services (Workspace, Players, ReplicatedStorage, etc.). Teleporting destroys the current DataModel and creates a new one. initializes. Multiple calls queue multiple scripts in order.
Use case
Essential for persistence across teleports in games with multiple places (e.g., lobby → game). Without this, scripts stop when the DataModelDataModelThe root Instance in Roblox's object hierarchy (game). Contains all services (Workspace, Players, ReplicatedStorage, etc.). Teleporting destroys the current DataModel and creates a new one. is destroyed during teleport. The queued code runs in the new place’s context with access to its globals and services.
Usage
Persist a script across teleports
queue_on_teleport([[print("I survived the teleport!")]])
game:GetService("TeleportService"):Teleport(12345)Parameters
code string Luau source code to execute after teleport.
Alias
Will be superseded by queueonteleport in future versions.