for i,v in pairs (game.Workspace:GetChildren()) do if v.ClassName == ("Part") then print 'hey' --Does print Instance.new("ClickDetector") --Right here, I am trying to insert a ClickDetector in all Parts end end
Looks like you did not specify the parent of the new ClickDetectors, look below!
for index, child in pairs(workspace:GetChildren()) do if child.ClassName == "Part" then print(child.Name .. " is a Part!") -- optional line local ClickDetector = Instance.new("ClickDetector") ClickDetector.Parent = child end end
The code above would create ClickDetectors in each of the parts in Workspace