Warp World

# Course Introduction

You can move from one world to another using the TeleportService function.

# Move to Another World

TeleportService can move users to a certain place, or move from one connected world to another. The movement is available when the connecting world and the world to move to have both been released. For this reason, it is not possible to test warp during production.

[{"Current World":"Published","World to Move":"Published","Warp or Not":"◯"},{"Current World":"Not Published","World to Move":"Published","Warp or Not":"◯"},{"Current World":"Published","World to Move":"Not Published","Warp or Not":"X"},{"Current World":"Not Published","World to Move":"Not Published","Warp or Not":"X"}]

  
When moving a user to another world, `WarpUserToWorldAndWait()` and `WarpUserToWorldAsync()` functions are used, and two pieces of data, such as the user ID to move and the world ID to move to, are required. If you want to use the data that the user collected from the current world in the new world to move to when a user warps to another world, you can transfer the data when the user moves by using `WarpUserToWorldAndWait()` and then access and acquire the data with GetWarpRecord(). For detailed information, please refer to [TeleportService](/apiReference?postId=315).  


> Tip You can warp to every world released, even if the creator has not made those worlds.

# See World ID

You can see WorldID with the URL of the world information page on the MapleStory Worlds official website. The numbers at the end of the URL may be used as a World ID.

  * https://maplestoryworlds.nexon.com/play/Number



[png](1675147124079c0e09e99888c4f9bb0ed894fa8d6ba59)

# Use Example

#### To Warp

Let's make it so a user can warp to another world through a portal.

[gif](16751473183921f72083c0b094c9fb0a4aa7d407d2b8d)

  1. New: Create a new Warp [png](Ect) component and add it to a portal.

  2. Add WorldId to Property and enter World ID on the Property Editor window.  
[png](16577946836778dbd808244d6421e99a67c482d4aa1b8)

  3. To make it so a user can move to the world assigned, write the following portal event:
         
         @Component
         script PortalWorldWarp extends Component
         @Sync
         property string WorldId = ""
         
         @ExecSpace("ServerOnly")
         method void Warp(string userId)
         local warpDataTable = {}
         warpDataTable.userId = userId
         
         local serializedData = _UtilLogic:TableToString(warpDataTable)
         
         _TeleportService:WarpUserToWorldAndWait(userId, self.WorldId, serializedData)
         end
         
         @EventSender("Self")
         handler HandlePortalUseEvent(PortalUseEvent event)
         --------------- Native Event Sender Info ----------------
         -- Sender: PortalComponent
         -- Space: Client
         ---------------------------------------------------------
         
         -- Parameters
         local PortalUser = event.PortalUser
         ---------------------------------------------------------
         
         self:Warp(PortalUser.Name)
         end
         end
         



    
    
    #### See If a User Entered into a World through a Warp
    With `GetWarpRecord()`, you can see if a user entered a world through a warp. 
    
    1. Create a new script component , and add it to Common.
    2. Write the following to see if a user entered the world via a warp:
        ```lua
    @Component
    script UserWarpChecker extends Component
        @ExecSpace("ServerOnly")
        @EventSender("Service", "UserService")
        handler HandleUserEnterEvent(UserEnterEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: UserService
        -- Space: Server
        ---------------------------------------------------------
    
        -- Parameters
        -- local ProfileCode = event.ProfileCode
        local UserId = event.UserId
        ---------------------------------------------------------
    
        local warpRecord = _TeleportService:GetWarpRecord(UserId)
    
        -- For a case of general world entry GetWarpRecord() returns nil.
        if warpRecord == nil then 
            return
        end
        end
    end
    

#### Check the Warped-From World

With `GetWarpRecord()`, you can see which world the user who moved by Warp came from.

  1. Create a new script component , and add it to Common.
  2. Write the following to see which world a user who moved using warp came from: 
         
         @Component
         script UserWarpRecordLoader extends Component
         @ExecSpace("ServerOnly")
         @EventSender("Service", "UserService")
         handler HandleUserEnterEvent(UserEnterEvent event)
         --------------- Native Event Sender Info ----------------
         -- Sender: UserService
         -- Space: Server
         ---------------------------------------------------------
         
         -- Parameters
         -- local ProfileCode = event.ProfileCode
         local UserId = event.UserId
         ---------------------------------------------------------
         
         local warpRecord = _TeleportService:GetWarpRecord(UserId)
         if warpRecord == nil then
             return
         end
         
         local currentWorldId = warpRecord.CurrentWorldId
         local prevWorldId = warpRecord.PreviousWorldId -- You can see the previous world.
         end
         end
         



    
    
    #### Deliver Data to Another World
    You can deliver a user's data to the world the user moves to.
    
    1. Create a new script component.
    2. Add a portal to the map, then add the created script component to the portal.
    3. You can deliver the data to another World by using `WarpUserToWorldAndWait()` and `UtilLogic` as below. 
        ```lua
    @Component
    script PortalWarper extends Component
        @Sync
        property string WorldId = ""
    
        @ExecSpace("ServerOnly")
        method void Warp(string userId)
        local warpDataTable = {}
        warpDataTable.testData = "test"
    
        local warpData= _UtilLogic:TableToString(warpDataTable)
    
        _TeleportService:WarpUserToWorldAndWait(userId, self.WorldId, warpData)
        end
    
        @EventSender("Self")
        handler HandlePortalUseEvent(PortalUseEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: PortalComponent
        -- Space: Client
        ---------------------------------------------------------
    
        -- Parameters
        local PortalUser = event.PortalUser
        ---------------------------------------------------------
    
        self:Warp(PortalUser.Name)
        end
    end
    

#### Get Data Delivered from the Previous World

You can receive the values delivered from the previous world.

  1. Create a new script component , and add it to Common.

  2. Write using `WarpUserToWorldAndWait()` and `UtilLogic` as below.
         
         @Component
         script UserWarpDataHandler extends Component
         @ExecSpace("ServerOnly")
         @EventSender("Service", "UserService")
         handler HandleUserEnterEvent(UserEnterEvent event)
         --------------- Native Event Sender Info ----------------
         -- Sender: UserService
         -- Space: Server
         ---------------------------------------------------------
         
         -- Parameters
         -- local ProfileCode = event.ProfileCode
         local UserId = event.UserId
         ---------------------------------------------------------
         
         local warpRecord = _TeleportService:GetWarpRecord(UserId)
         if warpRecord == nil then
             return
         end
         
         local warpDataTable = _UtilLogic:StringToTable(warpRecord.Data)
         log(warpDataTable.testData)
         end
         end
         



    
    
    
    ##### Reference Guide
    * [Teleportation](/docs/?postId=59)