PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

CanSendGameInviteAsync

CanSendGameInviteAsync indicates whether the given Player can invite other players to the current game. If they can, it returns true.

You should always use the result of this function before the SocialService/PromptGameInvite|PromptGameInvite function, since the ability to invite players can vary depending on the platform or player. Only after determining that invites are possible for this player, should you allow the player to opt-in (eg, a button press) to inviting others using the PromptGameInvite function.

Parameters

Name Type Default Description
0

The player instance of the user used to determine if the client can send a game invite

Returns

Return Type Summary

Whether the specified player can send a game invite


Code Samples


Sending a Game Invite

The following code sample demonstrates how to implement several SocialService APIs to allow players to invite other players to your game.

In order to work as expected, the code sample must be placed in a LocalScript descending from a GuiButton. When the Players/LocalPlayer touches or left clicks the GUI button, it executes openGameInvitePrompt() which opens the game invite prompt using SocialService/PromptGameInvite after firing canSendGameInvite() to check if the player can send game invites using SocialService/CanSendGameInviteAsync.

When the player closes the invite prompt, the invitePromptClosed() function connected to the SocialService/GameInvitePromptClosedevent fires.