Click Functions

How to make a block run a script when you click it

by Diamond_King5001

Author Avatar

Click functions

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:



function onClicked(playerWhoClicked)
    print("Block has been clicked!")


Output: When someone clicks the block then prints "Block has been clicked!"

View in-game to comment, award, and more!