Howdy, so i've used this script, which should work (roblox says), but, Ofcourse it doesn't,,,

This is the script.

local SocialService = game:GetService("SocialService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
 
local function canSendGameInvite(targetPlayer)
	print("Function 1 Triggered")
	local res, canSend = pcall(SocialService:CanSendGameInvite(targetPlayer))
	return res and canSend
end

**EDIT. I've changed "CanSendGameInvite" (above) to "CanSendGameInviteAsync" and still nothing happens. But, also no error output?**
 
local function promptGameInvite(targetPlayer)
	print("Function 2 Triggered")
	local res, canInvite = pcall(PromptGameInvite(targetPlayer))
	return res and canInvite
end
 
local function openGameInvitePrompt(targetPlayer)
	print("Function 3 Triggered")
	local canInvite = canSendGameInvite(targetPlayer)
	if canInvite then
		local promptOpened = promptGameInvite(targetPlayer)
		return promptOpened
	end
	return false
end
 
local function invitePromptClosed(senderPlayer, recipientIds)
	print("Function 4 Triggered")
	-- Handle custom logic for players invited by sender
end
 
local function inputBegan(input, gameProcessed)
	print("Function 5 Triggered")
	local inputType = input.UserInputType
	local touch = Enum.UserInputType.Touch
	local mouse1 = Enum.UserInputType.MouseButton1
 
	if inputType == touch or inputType == mouse1 then
		openGameInvitePrompt(player)
	end
end
 
script.Parent.InputBegan:Connect(inputBegan)
SocialService.GameInvitePromptClosed:Connect(invitePromptClosed)

Every function gets registered (By print()) but, this pops up in my Developer Console:

 CanSendGameInvite is not a valid member of SocialService
 Script 'Players.HeadlessDeathSpeaker.PlayerGui.ScreenGui.Frame.InputBegan.LocalScript1', Line 7 - upvalue canSendGameInvite
 Script 'Players.HeadlessDeathSpeaker.PlayerGui.ScreenGui.Frame.InputBegan.LocalScript1', Line 19 - upvalue openGameInvitePrompt
 Script 'Players.HeadlessDeathSpeaker.PlayerGui.ScreenGui.Frame.InputBegan.LocalScript1', Line 39

Anyone who figured out that it works?

Btw, i'm a Medium Scripter (not pro nor noob xD)

1 comment

0

There's too much going on in a single script instance.