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.
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
end
end
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!
Model:
Thank you to @EmeraldSlash for helping me not use a pcall.