Inviting friends doesn't work

local PlayerFriends = Player:GetFriendsOnline()

local function Invite(friend)
	print(friend)
	SocialService:PromptGameInvite(friend.UserName)
end

for _, friend in PlayerFriends do
	local Template = Objects:FindFirstChild("Friend")
	
	local New = Template:Clone()
	New.Name = friend.UserName
	New.Names.PlayerName.Text = "(@"..friend.UserName..")"
	New.Names.DisplayName.Text = friend.DisplayName
	New.Parent = Container
	
	New.Invite.MouseButton1Click:Connect(function()
		Invite(friend)
	end)
end

error:
image

Get more than 0 friends for it to work

‮‭Send me the Full code Please

local ReplicatedStorage = game.ReplicatedStorage
local SocialService = game:GetService("SocialService")
local Players = game.Players

local inviteOptions = Instance.new("ExperienceInviteOptions")
inviteOptions.PromptMessage = "Ask your friends to join the adventure!"

local Player = Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")

local Objects = ReplicatedStorage.Objects.GUI.Friends

local Modules = ReplicatedStorage.Modules.Client

local FriendsGui = PlayerGui.Friends.MainFrame
local Container = FriendsGui.Container
local Close = FriendsGui.Close

local PlayerFriends = Player:GetFriendsOnline()

local function Invite(friend)
	print(friend)
	SocialService:PromptGameInvite(friend.UserName)
end

for _, friend in PlayerFriends do
	local Template = Objects:FindFirstChild("Friend")
	
	local New = Template:Clone()
	New.Name = friend.UserName
	New.Names.PlayerName.Text = "(@"..friend.UserName..")"
	New.Names.DisplayName.Text = friend.DisplayName
	New.Parent = Container
	
	New.Invite.MouseButton1Click:Connect(function()
		Invite(friend)
	end)
end
	
Close.MouseButton1Click:Connect(function()
	FriendsGui.Visible = false
end)

gui

You should’ve showed us what line.

The first param needs to be a player object.

Documentation - Roblox Creator Hub exists so use it.

then it will open this panel, and I need to send an invitation to a specific person

basically do this

local inviteOptions = Instance.new("ExperienceInviteOptions")
inviteOptions.InviteUser = friend.UserId

SocialService:PromptGameInvite(Player,inviteOptions )

switch it out with ur SocialService:PromptGameInvite(friend.UserName) not sure if it works but it most probably should

image

this is a friend print
image

change friend.UserId to VisitorId

local inviteOptions = Instance.new("ExperienceInviteOptions")
inviteOptions.InviteUser = friend.VisitorId

SocialService:PromptGameInvite(Player,inviteOptions )
2 Likes