My code:
local SocialService = game:GetService("SocialService")
local player = game.Players.LocalPlayer
local P = player:WaitForChild'PlayerGui'
local button = P.ScreenGui.Buttons.Invite
local function canSendGameInvite(targetPlayer)
local res, canSend = pcall(SocialService.CanSendGameInvite, SocialService, targetPlayer)
return res and canSend
end
local function promptGameInvite(targetPlayer)
local res, canInvite = pcall(SocialService.PromptGameInvite, SocialService, targetPlayer)
return res and canInvite
end
local function openGameInvitePrompt(targetPlayer)
if canSendGameInvite(targetPlayer)then
return promptGameInvite(targetPlayer)
end
return false
end
local function onActivated()
openGameInvitePrompt(player)
end
button.Activated:Connect(onActivated)
button.Visible = canSendGameInvite(player)
button.Activated:Connect(onActivated)
Error : CanSendGameInvite not a valid member of Social Service.
This code was taken from roblox developer page. I’m making a Invite system in my game.