In this tutorial you learn how to make a block with a click detector that outputs a script when you click it.
First, just insert a part into the workspace and then inside of the part insert a click detector and a script.
Here we have 2 codes: The one is if you have the script inside the click detector and the other if you have the
code inside the part with the click detector. Every click function starts with this line:
function onClicked(playerWhoClicked)
Then the function closes with "end" like all other functions.
Now to make the function to be called when someone clicks the block we need to do this, if the script is inside the click detector:
script.Parent.Mouseclick:connect(onClick)
function onClicked(playerWhoClicked)
print("Block has been clicked!")
end
script.Parent.Mouseclic:connect(onClick)
Output: When someone clicks the block then prints "Block has been clicked!"