Ad
Log in to vote
0

How would I go about making this only check for friends at a certain place?

Asked by 5 days ago

I found this script on a youtube video, yes I know that is probably not the best, but I am still learning about teleport service. Anyway I am confused on how to make it so the script only searches for friends in the same place/game. I have tried changing a couple things but that just broke the script, so can I get some help with this please?

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:GetPlayersOnline()) 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(5596062006, v.VisitorId, LocalPlayer)
        end)
    end

    currentPosition = currentPosition + UDim2.new(0,0,0,100)
end

Answer this question