If you are looking for this block of code to work for every click detector in workspace called 'Dollar', then the best thing to do would be to use a for loop and search through the descendants in workspace.
Example
for _, detectors in pairs(workspace:GetDescendants()) do
if detectors:IsA("ClickDetector") and tostring(detectors) == "Dollar" then
end
end
A for loop will run the same code for every click detector that is named "Dollar"
Now we will attach an event to all of them
for _, detectors in pairs(workspace:GetDescendants()) do
if detectors:IsA("ClickDetector") and tostring(detectors) == "Dollar" then
detectors.MouseClick:Connect(function(playerWhoClicked)
print("OwO UwU")
end)
end
end
2 comments
im sorry i get how this works but im still having issues getting the click detector to reference the dollar >.< ive tried adding detectors.ClickDetector.MouseClick:Connect(function(playerWhoClicked) but that didnt work also :/
Did you use my exact code? If so, then change Dollar to dollar