How to make a invite friends gui

Hey Developers

So for a couple hours now I’ve been trying to figure out, how to make a invite gui on a top bar button, please tell me why this doesn’t work.

local replicatedStorage = game:GetService("ReplicatedStorage")
local topbarPlus = replicatedStorage:WaitForChild("HDAdmin"):WaitForChild("Topbar+")
local iconController = require(topbarPlus.IconController)
local gui = Instance.new("ScreenGui")



local shopIcon = iconController:createIcon("Shop", 4882429582, 1)
shopIcon:setToggleMenu(gui.Shop) -- Set the shop menu to be toggled by the icon
shopIcon:notify() -- Prompt a notification


local button = shopIcon
local SocialService = game:GetService("SocialService")
local player = game.Players.LocalPlayer

function onButtonPressed()
	local success, result = pcall(
		function()
    		return SocialService:CanSendGameInviteAsync(player)
    	end
    )

	if result == true then
		SocialService:PromptGameInvite(player)
	end
end

button.MouseButton1Click:Connect(onButtonPressed)
button.TouchTap:Connect(onButtonPressed)
1 Like

I used HD’s post for this. ForeverHD is his user name.

1 Like

its much easier than a lot of people think.
Put this in a local script:

local button = --where the button is
button.MouseButton1Click:Connect(function()
service:PromptGameInvite()
end)

Done!
No need to have CanSendInviteAsync()
it works fine for me without it.

1 Like

service is an unknown error, what do i make it as a variable to ?

local service = game:GetService("SocialService")