Warning when I use invite friends

Hello everyone, I get a warning when I use invite friends

PlayerGui.MainGui.MenuFrame.InviteFriendsTB.MouseButton1Down:Connect(function()	
	SoundService.ForGUI.GuiClick1:Play()

	PlayerGui.MainGui.Enabled = false
	local res, canSend = pcall(function()
		return SocialService:CanSendGameInviteAsync(LocalPlayer)
	end)
	if res and canSend then		
		local res2 = pcall(function()
			SocialService:PromptGameInvite(LocalPlayer)
		end)		
	end	
end)

> 
> 20:09:33.170  Unhandled Promise rejection:
> 
> -- Promise.Error(ExecutionError) --
> 
> The Promise at:
> 
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.ApiFetchUsersFriends:42
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.FetchUserFriends:18
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CorePackages.Packages._Index.RoactRodux.RoactRodux.connect:134 function dispatch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:56 function reFetch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:31 function init
> CorePackages.Packages._Index.React-a406e214-4230f473.React.ReactBaseClasses:259 function __ctor
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberClassComponent.new:742 function constructClassInstance
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:1051 function updateClassComponent
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:3592 function beginWork
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:240
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1908
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1891
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1834
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:877
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:825
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:304
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:259
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:82 function doWork
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:105 function performWorkUntilDeadline
> 
> ...Rejected because it was chained to the following Promise, which encountered an error:
> 
> 
> The Promise at:
> 
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.ApiFetchUsersFriends:37
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.FetchUserFriends:18
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CorePackages.Packages._Index.RoactRodux.RoactRodux.connect:134 function dispatch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:56 function reFetch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:31 function init
> CorePackages.Packages._Index.React-a406e214-4230f473.React.ReactBaseClasses:259 function __ctor
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberClassComponent.new:742 function constructClassInstance
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:1051 function updateClassComponent
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:3592 function beginWork
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:240
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1908
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1891
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1834
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:877
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:825
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:304
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:259
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:82 function doWork
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:105 function performWorkUntilDeadline
> 
> ...Rejected because it was chained to the following Promise, which encountered an error:
> 
> CorePackages.AppTempCommon.LuaChat.Utils.getFriendsActiveGamesPlaceIdsFromUsersPresence:13: attempt to index nil with '4174974106'
> CorePackages.AppTempCommon.LuaChat.Utils.getFriendsActiveGamesPlaceIdsFromUsersPresence:13
> CorePackages.AppTempCommon.LuaApp.Thunks.ApiFetchUsersPresences:21
> CorePackages.Packages._Index.Promise330.Promise330:154 function runExecutor
> CorePackages.Packages._Index.Promise330.Promise330:163
> 
> Promise created at:
> 
> CorePackages.AppTempCommon.LuaApp.Thunks.ApiFetchUsersPresences:17
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.ApiFetchUsersFriends:41
> CorePackages.Packages._Index.Promise330.Promise330:154 function runExecutor
> CorePackages.Packages._Index.Promise330.Promise330:163
> 
> 
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.ApiFetchUsersFriends:42
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Thunks.FetchUserFriends:18
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:15
> CorePackages.Packages._Index.roblox_rodux.rodux.thunkMiddleware:14
> CorePackages.Packages._Index.roblox_rodux.rodux.Store:98
> CorePackages.Packages._Index.RoactRodux.RoactRodux.connect:134 function dispatch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:56 function reFetch
> CoreGui.RobloxGui.Modules.Settings.Pages.ShareGame.Components.ShareGameContainer:31 function init
> CorePackages.Packages._Index.React-a406e214-4230f473.React.ReactBaseClasses:259 function __ctor
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberClassComponent.new:742 function constructClassInstance
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:1051 function updateClassComponent
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberBeginWork.new:3592 function beginWork
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:240
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1908
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1891
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:1834
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:877
> CorePackages.Packages._Index.ReactReconciler-a406e214-4230f473.ReactReconciler.ReactFiberWorkLoop.new:825
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:304
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.Scheduler:259
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:82 function doWork
> CorePackages.Packages._Index.Scheduler-a406e214-4230f473.Scheduler.forks.SchedulerHostConfig.default:105 function performWorkUntilDeadline
>   -  Client - Promise330:1302
>   20:09:48.218  Disconnect from ::ffff:127.0.0.1|58288  -  Studio

Maybe try it without the pcall, so basically this:

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

-- Inside the function
local canInvite = SocialService:CanSendGameInviteAsync(LocalPlayer)
if canInvite then
	SocialService:PromptGameInvite(LocalPlayer)
end

Please test it outside of roblox studio, via team test or a test server as well and make sure if it works then.

1 Like

I tried everything that you wrote, but it did not help, the warning remains

Use the same script you have made before and test it in other games, maybe your game is corrupted.

did not help the same in another place

Oh yeah and did you test it outside of roblox studio, so in an actual roblox game? This might be the reason why it is not working.