How would I check if a friends PlaceId is in the same universe as a player?

Hello, my game has multiple places, and I made a join friend system with Player:GetFriendsOnline() so it’s easy to join a friend in another place, everything works fine but the gui displays other games too, this can lead to errors because my place doesn’t allow third party teleports. Any help would be appreciated!

You should check out this function: TeleportService | Roblox Creator Documentation


local placeIds = {}

local currentInstance, errorMessage, placeId, instanceId = game:GetService("TeleportService"):GetPlayerPlaceInstanceAsync(userId)

if not currentInstance and table.find(placeIds, placeId) then
--Teleport the player to their friend using the instanceId

Thanks for your suggestion, though using tables might be quite annoying as my game is going to have a lot of places, I think that would be the best option

I would use a ModuleScript Package (with AutoUpdate on) that contains all of the PlaceIds so that you only have to update a single script when adding a new place.

1 Like

Quick question, if my table gets very large, will it lag some devices?