I had one button that was recognized by the script in InstanceAdded() and it printed its name but the event didnt fire when the button was clicked. everything else works except the clicked event.

local collectionservice = game:GetService("CollectionService")
local currentports = collectionservice:GetTagged("SellingButton")
local player = game.Players.LocalPlayer
local gui = player:WaitForChild("PlayerGui")
local buildgui = gui:WaitForChild("BuildGui")
local buildselect = buildgui:FindFirstChild("SelectBuild")
local addobj = game.ReplicatedStorage:WaitForChild("AddObject")
local mouse = player:GetMouse()
local ThreeDobjects = {}
function Input(object)
		print("input1")
			print("input2")
				local clicked = false
				local function MouseClick()
					clicked = true
				end
				local connection = mouse.MouseButton1Down:Connect(MouseClick)
				buildselect.Visible = false
				local objectghost = object:Clone()
				local ghostchil = objectghost:GetChildren()
				for i = 1,#ghostchil do
					ghostchil[i].Transparency = .5
					ghostchil[i].CanCollide = false
				end
				objectghost.Parent = workspace
				repeat
					wait()
					objectghost:SetPrimaryPartCFrame(mouse.Hit)
				until clicked == true
				objectghost:Destroy()
				addobj:InvokeServer(mouse.Hit,object.Name)
	end
function InstanceAdded(instance2)
	print(instance2.Name)
	local instance = instance2.Parent
	local object = instance:FindFirstChildOfClass("Model")
	local viewport = {viewinstance = instance,object}
	instance2.MouseButton1Click:Connect(function() Input(object) end)
	table.insert(ThreeDobjects,#ThreeDobjects,viewport)
end
function InstanceRemoved(instance)
	for i = 1,#ThreeDobjects do
		if(ThreeDobjects[i].viewinstance == instance)then
			table.remove(ThreeDobjects,i)
		end
	end
end
for i = 1,#currentports do
	InstanceAdded(currentports[i])
end
collectionservice:GetInstanceAddedSignal("SellingButton"):Connect(InstanceAdded)
collectionservice:GetInstanceRemovedSignal("SellingButton"):Connect(InstanceRemoved)