SocialService

Show Deprecated
Not Creatable
Service
Not Replicated

SocialService facilitates social functions that impact relationships made on the Roblox platform. Its primary usage is to show invite prompts to players which allow them to send invitation requests to their friends through SocialService:PromptGameInvite() and leverage signals when such requests are made.

Summary

Properties

Methods

PromptGameInvite(player: Instance, experienceInviteOptions: Instance)  

Prompts the given Player with the invite screen.

PromptIrisInvite(player: Instance, tag: string)  


CanSendGameInviteAsync(player: Instance, recipientId: number): boolean  YIELDS

Indicates whether the given Player can invite other players.

Events


Fires when a player closes an invite prompt.

Callbacks

OnIrisInviteInvoked(tag: string, irisParticipantIds: Array)  


Properties

Methods

PromptGameInvite

PromptGameInvite() displays an invite prompt to the local player through which they may invite their friends to the current experience. Before calling this method, you should use CanSendGameInviteAsync() to determine whether the player can send an invite, as this ability may vary depending on the platform or player.

See Player Invite Prompts for more details on implementing invite prompts, customizing prompts and notifications, and using launch data.

Parameters

player: Instance

The Player to prompt with the invite popup.

experienceInviteOptions: Instance

Optional ExperienceInviteOptions object for customizing the prompt.

Default Value: "nil"

Returns

Code Samples

Sending an Invite

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
local success, errorMessage = pcall(function()
SocialService:PromptGameInvite(player)
end)
end

PromptIrisInvite

Parameters

player: Instance
tag: string

Returns

CanSendGameInviteAsync

Yields

CanSendGameInviteAsync() returns true if the given Player can invite other players to the current experience. You should always use the result of this function before calling PromptGameInvite() since the ability to invite players may vary depending on the platform or player.

See Player Invite Prompts for more details on implementing player invite prompts, customizing prompts and notifications, and using launch data.

Parameters

player: Instance

The Player instance of the user potentially sending an invite.

recipientId: number

Optional Player.UserId of the potential recipient, used to check whether the sender can invite that specific recipient.

Default Value: 0

Returns

Whether the specified player can send an invite.

Code Samples

Sending an Invite

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
local success, canSend = pcall(function()
return SocialService:CanSendGameInviteAsync(sendingPlayer)
end)
return success and canSend
end
local canInvite = canSendGameInvite(player)
if canInvite then
local success, errorMessage = pcall(function()
SocialService:PromptGameInvite(player)
end)
end

CanSendIrisInviteAsync

Yields

Parameters

player: Instance

Returns

Events

GameInvitePromptClosed

This event fires when a player closes an invite prompt.

Parameters

player: Instance

The Player instance of the user who closed the prompt.

recipientIds: Array

No longer populated; an empty array.


IrisInvitePromptClosed

Parameters

player: Instance

Callbacks

OnIrisInviteInvoked

Parameters

tag: string
irisParticipantIds: Array

Returns