Invite GUI doesnt work

  1. What do you want to achieve?
    Working Invite GUI sending a message
  2. What is the issue?
    Invite GUI doesnt work (doesnt send a message)
  3. What solutions have you tried so far?
    Trying to fix with tutorials

Code:

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

script.Parent.MouseButton1Click:Connect(function(click)
	local success, result = pcall(
		function()
			return SocialService:CanSendGameInviteAsync(player)
		end
	)

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

try this

local canSend = game:GetService("SocialService"):CanSendGameInviteAsync(game.Players.LocalPlayer)

if canSend then
	script.Parent.MouseButton1Click:Connect(function()
		game:GetService("SocialService"):PromptGameInvite(game.Players.LocalPlayer)
	end)
end

i tried with yours but it doesnt work. Do i maybe need to set up an sentence in the code that he sends?

SocialService | Documentation - Roblox Creator Hub Will help you, scroll to Code sample, or just do this

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer

-- Function to check whether the player can send an invite
local function canSendGameInvite(sendingPlayer)
	local success, canSend = pcall(function()
		return SocialService:CanSendGameInviteAsync(sendingPlayer)
	end)
	return success and canSend
end

local function onClick()
	local canInvite = canSendGameInvite(player)
	if canInvite then
		local success, errorMessage = pcall(function()
			SocialService:PromptGameInvite(player)
		end)

        -- Warn in case it's failing
		if errorMessage then
			warn(errorMessage)
		end
	end
end

script.Parent.MouseButton1Click:Connect(onClick)


1 Like