SocialService
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
Events
Fires when a player closes an invite prompt.
Callbacks
Properties
Methods
HideSelfView
Returns
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
Optional ExperienceInviteOptions object for customizing the prompt.
Returns
Code Samples
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
ShowSelfView
Parameters
Returns
CanSendGameInviteAsync
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
Optional Player.UserId of the potential recipient, used to check whether the sender can invite that specific recipient.
Returns
Whether the specified player can send an invite.
Code Samples
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
Events
GameInvitePromptClosed
This event fires when a player closes an invite prompt.
Parameters
No longer populated; an empty array.