Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to detect if 1 of some buttons is pressed?

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?

1 answer

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.