Preview:
local clickPart = script.Parent
-- Create a ClickDetector and set its parent
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = clickPart
 
local function onPartClick(player)
	-- Output a message and randomly color the clicked part
	print(player.Name .. " clicked me!")
	clickPart.BrickColor = BrickColor.random()
end
 
clickDetector.MouseClick:Connect(onPartClick)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter