Topbar Invite Friends

i am using TopbarPlus to make an invite friends button here is the code

local Icon = require(game:GetService("ReplicatedStorage").Icon)
local SocialService = game:GetService("SocialService")
local Player = game.Players.LocalPlayer
local icon = Icon.new()

:setImage(10885655986)

local function onButtonPressed()
	local success, result = pcall(
		function()
			return SocialService:CanSendGameInviteAsync(Player)
		end
	)

	if result == true then
		SocialService:PromptGameInvite(Player)
	end
end

icon.selected:Connect(function()
	onButtonPressed()
end)

it does what it is suppose to do but every time i click out of the invite friends panel the button still stays selected. how can i fix this?

here’s what i mean;

before:

before

after

after

after i click on it the color is now blue but i want it to stay black please help

2 Likes

deselect?
icon.selected:Connect(function()
end)
this topbar stuff is complicated too much

you can check the topbar

im going to try making a custom theme and changing the selected color to the deselected color

Simply call icon:deselect() immediatly after it is selected.

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SocialService = game:GetService("SocialService")

local Icon = require(ReplicatedStorage.Icon)

local localPlayer = Players.LocalPlayer
local icon = Icon.new():setImage(10885655986)

local function onIconSelected()
	local success, canInvite = pcall(function()
		return SocialService:CanSendGameInviteAsync(localPlayer)
	end)

	if success and canInvite then
		SocialService:PromptGameInvite(localPlayer)
	end
end

icon.selected:Connect(function()
	icon:deselect()
	onIconSelected()
end)

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