How To Allow Players To Invite Their Friends With A Simple Click! (Increase Player Counts!)

Welcome to my tutorial on SocialService, and inviting players.

Hey there! I’m making this tutorial because there are almost NO tutorials on how to make an invite-player-GUI. So here we go!
First, make a screengui, and make a button in it, and then make a localscript inside of the button.
Screen Shot 2020-04-27 at 1.13.44 PM
Just like the photo above.
Open the localscript.
First in the localscript, we are going to get the button and “SocialService”, and of course the player.

local button = script.Parent -- reference the button
local SocialService = game:GetService("SocialService") --get social service
local player = game.Players.LocalPlayer --get the player

Now, lets get a function, and check if the player can send invites, then prompt them!

function click()
if SocialService:CanSendGameInviteAsync(player) then -- check if they can send invites
   SocialService:PromptGameInvite(player) --prompt the player with the window

And of course, we need to make the function work, so add this below alll of the code

button.MouseButton1Click:Connect(click) --mouseclick, computer click
button.TouchTap:Connect(click) --touchtap, mobile tap

Final Product:
(gif is gone, I’ll replace it soon enough.)

I hope that you found this helpful!
If anything here seems off, please let me know, thank you!


Thank you to @EmeraldSlash for helping me not use a pcall.


Very useful, I’ll use it sometime! :call_me_hand:

1 Like

There’s no need for any of that pcall stuff :wink: The CanSendGameInviteAsync method doesn’t appear to be meant to throw errors frequently (correct me if I’m wrong here). This also means there’s really no reason to suppress errors using pcall unless you really want to keep the output ultra clean. You can do all of it in two lines:

if SocialService:CanSendGameInviteAsync(player) then

I also suggest that you test your code and get it working before posting it as a tutorial. It doesn’t help people very much if it doesn’t work. The original code you posted would never actually send an invite, because you were setting the result of the method call to a local variable result (creating its own variable) it doesn’t actually appear in the main result variable. To make it work you could just return the value, instead of setting it to a variable.


Oh! Thank you for this, I’ll update the code and put you somewhere!
I’m not the best scripter, so I don’t know much yet.

Thanks for the Tip, I’ll try it on my Next project!