Cant click ImageButtons made by a script

Im trying to create a Shop gui but when I clone a button and put it in the frame its not clickable, im wondering if theres any sanity checks I have to do or something just with the game.? The premade buttons work fine if they are already inside the frame before the game starts.

ServerScript:

function onPlayerAdded(plr)
	local playerGui = plr:WaitForChild('PlayerGui')
	for i,skin in pairs(Products.Skins) do
		local skinName = skin.name
		local skinDesc = skin.description
		local skinId = skin.id

		local success,ownsProduct = pcall(function()
			return MarketPlaceService:PlayerOwnsAsset(plr, skinId) 
		end)

		if success then
			if ownsProduct then
				print("owns product")
			else
				print(plr.Name.." does not own "..skinName)
				
				local skinTemp = playerGui.ScreenGui.Tab.TabClient.Skin:Clone()
				skinTemp.Name = skinName
				skinTemp.Description.Value = skinDesc
				skinTemp.Parent = playerGui.ScreenGui.Tab.SkinsFrame
			end
		else
			warn("Error checking asset ownership for "..plr.Name..", asset "..skinId.." "..skinName..": "..tostring(ownsProduct))
		end
	end
end

LocalScript:

for i,button in pairs(script.Parent.SkinsFrame:GetChildren()) do
	if button and button:IsA("ImageButton") then
		button.MouseButton1Click:Connect(function()
			if button.Name==SkinsFrame2.SkinName.Text then return end

			local SkinName = button.Name
			local Description = button.Description.Value
			local Thumbnail = button.Image

			SkinsFrame2.SkinName.Text = SkinName
			SkinsFrame2.Description.Text = tostring(Description)
			SkinsFrame2.Thumbnail.Image = Thumbnail
			
			print(SkinName)
			
			SkinsFrame2.WearButton.MouseButton1Click:Connect(function()
				if SkinsFrame2.SkinName.Text == "Skin" then return end

				if SkinsFolder:FindFirstChild(SkinName) then
					ServerRemote:FireServer("WearSkin",SkinName)
				else
					return warn("Skin is not in Skins Folder")
				end
			end)
		end)
	end
end

I am assuming you done the basic debugging and it does / does not print("Click") before the if button.Name == blah. If so When are you calling your local script? If youre calling it soon as the game loads then add the buttons after those new buttons won’t have any connections with them. If you add a task.wait(5) then make sure the buttons are added on the server then run your local script for loop it should work.

I honestly have no clue why i havent tried a task.wait yet i think im sleep deprived

Try that and hopefully it should be a temp fix. As a permanent fix now…After everything is done loading on the server. Fire the client through a Remote Event. and when the client receives it add the connection for the buttons (as you have your local script above). Hopefully it works though.

It doesn’t detect the new button because you didn’t register its click connection after cloning.

The code in the local script registered only the buttons that existed at the start of the game to be clicked and if you add more buttons it’s not going to automatically add its connection too, so you have to do it manually ie. run the local script code again after cloning the ImageButton.

You could fire a RemoteEvent after cloning which will in turn run the local script code again.

Try the clone() part from the LocalScript maybe.