local Template = script.Template
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local currentPosition = UDim2.new(0,0,0,0)
local TeleportService = game:GetService("TeleportService")
local function cloneObject(object, Parent)
local clonedObject = object:Clone()
clonedObject.Parent = Parent
return clonedObject
end
for i,v in pairs(LocalPlayer:GetFriendsOnline()) do
local FriendImage = cloneObject(Template, script.Parent)
FriendImage.Image = Players:GetUserThumbnailAsync(v.VisitorId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
FriendImage.Position = currentPosition
FriendImage.Name = v.UserName
FriendImage.Username.Text = v.UserName
if v.LastLocation then
FriendImage.JoinButton.MouseButton1Click:Connect(function()
print(v.GameId, v.PlaceId)
TeleportService:TeleportToPlaceInstance(v.PlaceId, v.VisitorId, LocalPlayer)
end)
end
currentPosition = currentPosition + UDim2.new(0,0,0,100)
end
This isn’t really related to the topic, but why would you want to create a screen that takes players away from your game? (if it’s a “hub” kind of game then ignore this question)
Ohhh, I think I understand what you’re trying to do, scratch the other reply. About the error it throws at you - did you try joining a different friend? The person you tried to join is probably in a private game (or a restricted one, whatever that means).
I never used TeleportService, but I think you need both the PlaceId and the GameId - not sure what the difference is. Try this instead:
if v.LastLocation then
FriendImage.JoinButton.MouseButton1Click:Connect(function()
print(v.GameId, v.PlaceId)
TeleportService:TeleportToPlaceInstance(v.PlaceId, v.GameId, LocalPlayer)
end)
end
Edit: Changed v.VisitorId to v.GameId.
Another edit:
PlaceId
number
The place ID of the friend’s last location.
GameId
string
The DataModel.JobId of the friend’s last location.
Our game had the exact same problem but it went away on its own. According to this thread and reply, it is an issue on Roblox’s end and they attempted to fix it. I suppose you could bump the thread with your input, as there are plenty of developers reporting that whatever Roblox did didn’t work. Otherwise, it’ll work from time to time, but there’s no telling when.
Another reply in that thread said that it started to work when they ran it off of the server instead of following the DevHub documentation which says to run it from the client. You could try that if that’s not already the case.
Hey! Roblox has a Default Service part of the Social service, Here is a Little Code to help you out, This is a child of a Button.
local social = game:GetService("SocialService")
script.Parent.MouseButton1Click:Connect(function()
social:PromptGameInvite(game.Players.LocalPlayer)
end)
Ignore the idea of saving it to a data store, it’s not a great method at all.
This method returns the JobId for online friends.
This can be also read by the client. So you can get the list via client too, and then just use a remote event to teleport the player into another server;