Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I teleport to a friend's game?

Asked by
Validark 1580 Snack Break Moderation Voter
7 years ago

I am trying to find the proper API to teleport to a friend's game.

If you join this game and hit Alt + M, it opens up a menu where you can join a friend's game. I would like to know how to replicate this.

The TeleportService doesn't seem to mention how to do this.

1
game:GetService('TeleportService'):Teleport(PlaceId, game.Players.YourPlayerName) RubenKan 3615 — 7y

1 answer

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
7 years ago
Edited 7 years ago
local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

local function FollowPal(Player, Id)
    --- Teleports Player to another user's game
    -- @param Player the Player that will be teleported
    -- @param integer Id The userId of the Player they want to teleport to

    local Successful, Error, PlaceId, ServerId = TeleportService:GetPlayerPlaceInstanceAsync(Id)

    if Successful then
        TeleportService:TeleportToPlaceInstance(PlaceId, ServerId, Player)
    else
        print("Teleport error:", Error)
    end
end

FollowPal(Players.Narrev, 34011054)
Ad

Answer this question