This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
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
The player instance of the user used to determine if the client can send a game invite
Whether the specified player can send a game invite
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
When the player closes the invite prompt, the invitePromptClosed() function connected to the