Collapse Sidebar


The Deactivated event fires when the left mouse button is released while a Tool is equipped.

This function is used to perform an action when the player stops using a tool. For instance, a tool may make a player fly until they release their left mouse button.

The below code, when placed in a LocalScript, would create a tool in the Players/LocalPlayer|LocalPlayer's Backpack. It will print “Tool deactivated” when the player releases the left mouse button, while the tool is equipped.

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

Code Samples

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.