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:
after
after i click on it the color is now blue but i want it to stay black please help
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)