CanSendGameInviteAsync is returning true on Studio but on the actual game it is returning nil

  1. What is the issue? Include screenshots / videos if possible!
    CanSendGameInviteAsync is returning true on Studio but on the actual game it is returning nil.(for success and canSend)

  2. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    There was no solutions on the devfourm. I tried simplifying the code, and tens of other things I forgot.

  3. Code

local success, canSend = pcall(function()
	return SocialService:CanSendGameInviteAsync(player)
end)
	
if success and canSend then
	print("YES!")
	local gameInviteOptions = Instance.new("ExperienceInviteOptions")
	gameInviteOptions.PromptMessage = "Invite your friends for +10% money each friend!"
	gameInviteOptions.InviteMessageId = "48509150-44c6-6141-a987-0be16eb37cd0"
	SocialService:PromptGameInvite(player, gameInviteOptions)
else
	print(success, canSend)
end
  1. Output
    nil nil

Also sorry if this post is in the wrong category, I don’t really know what category to put it in…

I replaced your script with this one:

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)
	print(success, canSend)
	return success and canSend
end

local canInvite = canSendGameInvite(player)
if canInvite then
	local gameInviteOptions = Instance.new("ExperienceInviteOptions")
	gameInviteOptions.PromptMessage = "Invite your friends for +10% money each friend!"
	gameInviteOptions.InviteMessageId = "48509150-44c6-6141-a987-0be16eb37cd0"
	SocialService:PromptGameInvite(player)
end

Dude. I am so sorry, like 5 days after that post my code was working without it being edited. Though thanks!

Some players might not be able to invite other players from what the documentation says. Perhaps that’s why.

If it’s you who is testing it, are you sure you’re able to invite players?

I am sure I am allowed to invite people, because I can in other games.

Make sure to mark a post as the solution.

That script doesn’t give the PromptGameInvite the GameInviteOptions.

Sorry. Here’s the fixed script.

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)
	print(success, canSend)
	return success and canSend
end

local canInvite = canSendGameInvite(player)
if canInvite then
	local gameInviteOptions = Instance.new("ExperienceInviteOptions")
	gameInviteOptions.PromptMessage = "Invite your friends for +10% money each friend!"
	gameInviteOptions.InviteMessageId = "48509150-44c6-6141-a987-0be16eb37cd0"
	SocialService:PromptGameInvite(player, gameInviteOptions)
end