Invite Friends with a Part that has a TextButton

  1. Inviting Friends and others with a TextButton inserted in a Part.
    By clicking the Parts-TextButton it should open the Friend Invitation option.

  2. The Problem is it doesn’t work.
    Maybe it has no way to open something in ScreenGui?
    Or my script is doing something wrong.

Script:

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

function onButtonPressed()
	local success, result = pcall(function()
		return SocialService:CanSendGameInviteAsync(player)
	end)
	
	if result == true then
		SocialService:PromptGameInvite(player)
	end
end

button.MouseButton1Click:Connect(onButtonPressed)
button.TouchTap:Connect(onButtonPressed)
  1. Nothing in kind has ever been made before, so that’s why I am here.
1 Like

Is this a localscript? If so then it can’t be in a part. it has to be in the player, startergui, starterpack etc.

What I’d do on your place is make a part, create a surfacegui in startergui, set it’s adornee (in it’s properties) to the part, put a textbutton in the startergui and put this as a localscript into the textbutton.

2 Likes

Thanks for the Solution.
I learned something new today! (At Christmas)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.