TeleportService error

Output says: Argument 2 missing or nil - 8th line
JobId and PlaceId are in Attributes

local TPService = game:GetService("TeleportService")
local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local JobId = script.Parent.Parent:GetAttribute("JobId")
	local PlaceId = script.Parent.Parent:GetAttribute("PlaceId")
	
	TPService:TeleportToPlaceInstance(PlaceId, JobId, plr) -- here error
end)
1 Like

The error basically tells you that JobId is nil. Have you set your JobId to what it’s supposed to be? Remember, a JobId is the Id of the server that you’re currently in, or any server Id in the place.

1 Like

You need to be in the server first, you can’t test in Roblox studio

1 Like

Yes, when i run this command via command bar it’s printing (Cannot teleport in roblox studio). I setted same jobid and placeid

1 Like

When i run it in command bar it’s printing (Cannot teleport in roblox studio)
It’s problem is not because in roblox studio cannot teleport

You cannot teleport in Roblox Studio, as it stated there.

Do not test teleportation it in Roblox Studio, your error will sometimes not be what it should be if you test teleportation there.

Test it in real server.

Extra: If you did a normal Play test in Roblox Studio, changing the properties in the Properties tab will only change it locally, meaning a server script wouldnt be able to see the changes

I’m get the JobId and PlaceId from GetOnlineFriends() function

I installing the roblox win10 app for test, bc i can’t be in game on 2nd account

Same output error

_________________

Then your JobId is nil. May you show how you set your JobId? Like show the script

local scroll = script.Parent
local template = script.FriendCardTemplate
local plr = game.Players.LocalPlayer

local function LoadOnlineFriends()
	local OnlineFriends = plr:GetFriendsOnline(200)
	for i,v in pairs(OnlineFriends) do
		print(v.UserName)
		local Card = template:Clone()
		Card.Parent = scroll
		Card.Info.DisplayName.Text = v.DisplayName
		Card.Image = game.Players:GetUserThumbnailAsync(v.VisitorId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
		
		if v.LocationType == 1 or v.LocationType == 4 then
			Card:SetAttribute("IsPlaying", true)
			Card:SetAttribute("JobId", v.GameId)
			Card:SetAttribute("PlaceId", v.PlaceId)
			Card.IsPlaying.Visible = true
		end
	end
end

LoadOnlineFriends()

JobId is a string value. Is your attribute value for JobId a string value? When you try to put a string value to an attribute that only accepts number value, it causes the value to be nil. That’s probably why it said that JobId is nil.

image

oh. I named attributes “CurrentJobId” and "“CurrentPlaceId”
and i require the “JobId” and “PlaceId”
it’s can’t find it

third my stupid error

oh. I named attributes “CurrentJobId” and "“CurrentPlaceId”
and i require the “JobId” and “PlaceId”
it’s can’t find it

Looks like the reason why it said that it was nil, tell us if it’s fixed or if there’s any more related problems.

Yes, it’s fixed!
:happy4:

30ch30ch