Collapse Sidebar


Activated is not called if the Ctrl key is pressed during a click.

The Activated event fires when the player clicks while a Tool is equipped.

This function is used to perform an action when the player uses the tool. For instance, when the player clicks while a Rocket Launcher tool is equipped, the activated event executes the code to create and launch a rocket.

The below code, when placed in a LocalScript, would create a tool in the Players/LocalPlayer|LocalPlayer's Backpack. It will print “Tool activated” when the player clicks while the created tool is equipped.

local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.Parent = game.Players.LocalPlayer.Backpack
function onActivation()
    print("Tool activated")

Code Samples

Creating a Colorful Brick Tool

The code below creates a new tool and places into the Players/LocalPlayer|LocalPlayer's Backpack. Then, the code equips the tool for the player user Humanoid/EquipTool.

When the tool is equipped and the player uses it (e.g. pressed their mouse button in-game), the code spawns a new BasePart|part at the position of the click using the Humanoid/TargetPoint position. The code also sets several of the part’s properties, such as giving it a random BasePart/BrickColor.

Player Fly Tool

The code below demonstrates the functionality of several Tool events, including Tool/Activated, Tool/Deactivated, and Tool/Unequipped.

The code, when placed in a LocalScript in the StarterPlayer.StarterCharacterScripts folder inserts and controls a tool in the Players/LocalPlayer|LocalPlayer's Backpack that allows the player to fly through the sky when used.

In order to ensure that the player stops flying when the player unequips the tool, the code uses the tool’s Unequipped event to turn set the fly boolean to true and turn stop flying until the tool is reequipped and activated again.