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)
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.
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
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.