How do i make gui that can only be clicked once

So im trying to make it so when the player joins a party the can’t click the join button anymore but when the leave the party the can click it again so they can join how would i do this?


game.ReplicatedStorage.Events.JoinParty.OnServerEvent:Connect(function(player, level, partyowner)
	local players = {}
	local rep = game:GetService("ReplicatedStorage")
	local playerframe = rep:WaitForChild('DungeonTemplates').PlayerJoin

	
	
	for i, v in pairs(game.Players:GetPlayers()) do
		if v.Name == partyowner then
			table.insert(players, v)
		end
	end

	if player.Data.Level.Value >= level then
		table.insert(players, player)
	end
	
	for _, v in ipairs(players) do
		local ui = playerframe:Clone()
		ui.Parent = player.PlayerGui.PlayGui.PlayerParty.Duplicates
		ui.TopInfo.plrname.Text = v.Name
	end
	
	local connection; connection = game.Players.PlayerRemoving:Connect(function(player)
		if player.Name == partyowner then
			players = {} -- cache the array
			connection:Disconnect() -- disconnect the event to prevent memory leaks
		end
	end)

end)
1 Like

Just debounce it.

local clicked = false
local ui = script.Parent -- Path


ui.MouseButton1Up:Connect(function()
    if clicked == false then
        clicked = true
        -- Rest Of Your Script
    end
end)