Collapse Sidebar


The Button2Down even fires when the the player presses their right mouse button.

This can also be accessed from a Tool. For example, when placed in a LocalScript, the code below prints Button2Down whenever the right mouse button is pressed:

local Tool = script.Parent --make sure this is a Tool object


Developers can find out the position of the mouse in world-space, and if it is pointing at any BasePart, using the Mouse/Hit and Mouse/Target properties.

For information on how to obtain the mouse object, please see the Mouse page.

Note, developers are recommended to use UserInputService instead of the Mouse object in new work.

Code Samples

Color Randomizer Tool

The following code sample, when placed in StarterPlayerScripts will create a tool in the player’s backpack that, once equipped, will change the BasePart/BrickColor of every BasePart the player clicks on.