Teleportation Issue

  1. What do you want to achieve? Keep it simple and clear!
    I want to join a player via it’s playerid, however each time it errors and keeps saying “Place is restricted.”
  2. What is the issue? Include screenshots / videos if possible!
    Screenshot by Lightshot
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked at the wiki numerous times, I cannot figure this out.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- A fully extensible and type-safe admin-commands console
-- @documentation https://github.com/evaera/Cmdr/blob/master/README.md
-- @source https://github.com/evaera/Cmdr
-- @rostrap Cmdr
-- @author evaera 

return function (context, playerid)
    local Players = game:GetService("Players")
-- Memoization: since these results are rarely (if ever) going to change
-- all we have to do is check a cache table for the name.
-- If we find the name, then we have no work to do! Just return the user id (fast).
-- If we don't find the name (cache miss), go look it up (takes time).
local cache = {}

local commandexecutor = context.Executor
local commandexecutor2 = tostring(commandexecutor)
print(commandexecutor)
print(commandexecutor2)
local id = Players:GetUserIdFromNameAsync(commandexecutor2)
print(id)

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")


local success, errorMessage, placeId, jobId = pcall(function()
       return TeleportService:GetPlayerPlaceInstanceAsync(playerid)
end)
    if success then
		print("job: "..jobId)

local userId = id -- replace with player's userId
print(userId)
 
-- find the player
local player = Players:GetPlayerByUserId(userId)
 
-- teleport the player
TeleportService:TeleportToPlaceInstance(placeId, jobId, player) 
	else
		print("error is "..errorMessage)
end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

local success, errorMessage, placeId, jobId,realJobId = pcall(function()

realJobId is the actual job ID you need to use.

1 Like