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)
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.
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
Output
nil nil
Also sorry if this post is in the wrong category, I don’t really know what category to put it in…
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
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