this is the code it is in local script and the local script is in a button
local button = script.Parent
local SocialService = game:GetService("SocialService")
local player = game.Players.LocalPlayer
function onButtonPressed()
local success, result = pcall(
function()
return SocialService:CanSendGameInviteAsync(player)
end
)
end
if result == true then
SocialService:PromptGameInvite(player)
end
end
button.MouseButton1Click:Connect(onButtonPressed())
button.TouchTap:Connect(onButtonPressed())

1 comment
Provide the error next time so others can be better equipped to assist you.