Friend Follow Script Help

Sup i am trying to make a Local script that get your online friends and teleports you to the place that your friend is playing but it is not returning me it right can you guys tell me what is wrong or give me an better option to make this?

The Script:

local Player = game.Players.LocalPlayer
local PlayerGuis = Player.PlayerGui:WaitForChild("MainGui"):WaitForChild("Frame")
local Teleport = game:GetService('TeleportService')
local MainGameId = game.GameId -- replace with your main game id

PlayerGuis.PlayButtom.Activated:Connect(function()-- ignore this function
	Teleport:Teleport(MainGameId,Player)
end)

PlayerGuis.AfkWorld.Activated:Connect(function()-- ignore this function
	--Teleport:Teleport(Place the afk world place id here,Player)
end)


PlayerGuis.FollowAFriend.Activated:Connect(function()
	local Players = game:GetService("Players")

	local FriendName = PlayerGuis.FollowAFriend.PlayerFollowName

	local success, result = pcall(Player.GetFriendsOnline, Player, 200)
	
	print(FriendName.Text)
	if success then
		for _, friend in pairs(result) do
			print(friend.UserName)
			print(friend.PlaceId,friend.JobId)
			if FriendName.Text == friend.UserName then
				Teleport:TeleportToPlaceInstance(friend.PlaceId,friend.JobId,Player)
			else
				FriendName.Text = "Player is Not Playing This Game!"
			end
		end
	else
		warn("Failed to get online players: " .. result)
	end
end)
1 Like

This post below may help you out a bit.

You can directly teleport the player to the server instance ID

1 Like