hello so i have money, or better known as a part in workspace and i have this clickdector code that only works for one dollar, code below, but it does not work with the parts that are cloned
game.Workspace:WaitForChild("dollar").ClickDetector.MouseClick:Connect(function() print("WOWWWWWWW") end)
MAKE SURE TO PUT THE SCRIPT INSIDE THE PART.
script.Parent.ClickDetector.MouseClick:Connect(function() - - Event end)
Now if you clone the part, the script should be cloned as well. The reason why your code didn't work is because you told the script to look for that object only and not any other objects like it. It should work now.
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 --your code 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