Hey. So I have this script where on client I collect all tags and then run a loop to detect clicking on them. When I add a new object and add a tag on them via server it receives on client and adds to the collection but the loop on client does not pick it up, why is this? How would I fix this? Thanks.
local CakePickup = CollectionService:GetTagged("CakePickup")
--Insert New Cakes (Gets added on server)
CollectionService:GetInstanceAddedSignal("CakePickup"):Connect(function(part)
table.insert(CakePickup, part)
end)
--Click Detector for Cake Pickups
for _, ClickDetector in pairs(CakePickup) do
Code Here
end
Since this loop only runs when this script is initialized, any cakes added after that will not have the mouse event hooked up, even though they are in the CakePickup table.