For example, i have a script, which creates 10 numbered parts with ClickDetectors
for i = 1,10 do p = Instance.new("Part",workspace) p.Name = i p.Position = Vector3.new(0,i,0) c = Instance.new("ClickDetector",p) end
And if one of those buttons is pressed, paint pressed button in blue. How do i do it?
ClickDetectors have a MouseClick
event you can use:
for i = 1,10 do p = Instance.new("Part",workspace) p.Name = i p.Position = Vector3.new(0,i,0) c = Instance.new("ClickDetector",p) c.MouseClick:connect(function() p.BrickColor = BrickColor.new("Bright blue") end) end