For detecting a click on a certain block, would I use
function onClicked() --? end
or would I use something else, like MouseButtonDown?
You'd put a ClickDetector in the brick and put a script inside the detector going something like this:
script.Parent.MouseClick:connect(function() print(script.Parent.Parent.Name.." was clicked!") end)
For more information go to the Wiki Page
It would go something like this, for example:
H = game.Workspace.Part function Clicked(Part) H.Transparency = 1 wait(5) H.Transparency = 0 end script.Parent.ClickDetector.MouseClick:connect(onClicked)
Well, what you have so far:
function onClicked() --? end
That by itself is not really a function, onClicked is just a name. You could do function DatClickBro() or anything else, as that is just the name of the function. What makes it work is CALLING the function, some people add it to the end and some put it right at the front.
So first thing you need to do is make sure there is a click detector in the brick, then add a script to the brick.
Then do something like this:
function onClicked() --OnClicked is the name of the function script.Parent.Color = math.random()--If this doesn't make the color random then take the math. out, I'm not 100% sure if it's math.random() or random() for this type of thing since it's not a number value. end script.Parent.ClickDetector.MouseClick:connect(onClicked)--This is calling the function