Roblox UtilitiesDevlHub Roblox Documentation

Class

Tool

Inherits
BackpackItem › Model › PVInstance › Instance › Object
Memory category
BaseParts
Subclasses
1

An object, such as a weapon, that can be equipped by a Humanoid.

A Tool is an object that a Humanoid object can equip. For players, they are stored in a Backpack object parented to a Player object. In-experience, players may have multiple tools which appear as icons at the bottom of the screen. Equipping a tool moves it from the Backpack and into a Player.Character model in the Workspace. By default, tools are held in the right hand and have a handle in them, which is a BasePart named Handle inside (although one isn't required if Tool.RequiresHandle is false). Tools that are to be provided to (re)spawning players should be stored in the StarterPack.

Properties 10#

CanBeDroppedbooleanControls whether the player can drop the tool.ReadSafe
EnabledbooleanRelates to whether or not the tool can be used.ReadSafe
GripCFrameStores the tool's "grip" properties as one CFrame.ReadSafe
GripForwardVector3Represents the R02, R12, and R22 values of the grip CFrame rotation matrix.ReadSafeHiddenNotReplicated
GripPosVector3The positional offset of the tool's weld matrix.ReadSafeHiddenNotReplicated
GripRightVector3Represents the R00, R10, and R20 values of the grip CFrame rotation matrix.ReadSafeHiddenNotReplicated
GripUpVector3Represents the R01, R11, and R21 values of the grip CFrame rotation matrix.ReadSafeHiddenNotReplicated
ManualActivationOnlybooleanControls whether the Tool can be activated without executing Tool:Activate().ReadSafe
RequiresHandlebooleanDetermines whether a Tool functions without a handle.ReadSafe
ToolTipstringControls the message displayed when the player's mouse hovers over the tool in their backpack.ReadSafe

CanBeDropped: boolean#

ReadSafe

The CanBeDropped property controls whether the player can drop the Tool.

If true, when the backspace button is pressed, the tool will be parented to Workspace and removed from the player's Backpack. If false, nothing will happen when backspace is pressed, and the tool will remain equipped.

Enabled: boolean#

ReadSafe

The Enabled property relates to whether or not the Tool can be used. This is useful if you want to prevent a player from using a tool, but don't want to remove it from their Backpack.

When set to true, the player can use the tool. When set to false, the tool is disabled and the player cannot use it; this prevents the tool from being activated or deactivated by the Tool:Activate() and Tool:Deactivate() methods, and it prevents the Tool.Activated and Tool.Deactivated events from firing.

Grip: CFrame#

ReadSafe

The Grip property stores the tool's "grip" properties as a single CFrame. These properties position how the player holds the tool and include GripUp, GripRight, GripForward, and GripPos.

GripForward: Vector3#

HiddenNotReplicatedReadSafe

One of the properties that specifies a tool's orientation in a character's hand. This represents the R02, R12, and R22 values of the grip CFrame rotation matrix.

Other tool properties that control how a character holds a tool include Tool.GripUp, Tool.GripRight, and Tool.GripPos. All of these properties are stored in a single CFrame in the Tool.Grip property.

GripPos: Vector3#

HiddenNotReplicatedReadSafe

This property controls the positional offset of the tool's weld matrix. It is one of several properties used to position how the player character holds the tool.

Other properties that control how a character holds a tool include Tool.GripUp, Tool.GripRight, and Tool.GripForward. All of these properties are stored in a single CFrame in the Tool.Grip property.

GripRight: Vector3#

HiddenNotReplicatedReadSafe

One of the properties that specifies a tool's orientation in a character's hand. This represents the R00, R10, and R20 values of the grip CFrame rotation matrix.

Other tool properties that control how a character holds a tool include Tool.GripUp, Tool.GripForward, and Tool.GripPos. All of these properties are stored in a single CFrame in the Tool.Grip property.

GripUp: Vector3#

HiddenNotReplicatedReadSafe

One of the properties that specifies a tool's orientation in a character's hand. This represents the R01, R11, and R21 values of the grip CFrame rotation matrix.

Other tool properties that control how a character holds a tool include Tool.GripRight, Tool.GripForward, and Tool.GripPos. All of these properties are stored in a single CFrame in the Tool.Grip property.

ManualActivationOnly: boolean#

ReadSafe

This property controls whether the Tool can be activated without explicitly executing Tool:Activate() in a script.

When set to true, the tool will only fire Tool.Activated when Tool:Activate() is called. This also suppresses the ContextActionService:BindActivate() function.

When set to false, mouse clicks (when the tool is equipped) will also fire Tool.Activated.

RequiresHandle: boolean#

ReadSafe

This property determines whether a Tool functions without a handle.

A tool has a handle when it contains a child part named Handle. Tools with handles typically require the player equipping them to hold an object to use them, for instance weapons. Tools without handles typically don't require the player equipping them to hold anything to use them, for instance "fly" or "summon" tools.

When set to true, the tool will function only with a handle. When set to false, the tool will function even without a handle.

ToolTip: string#

ReadSafe

The ToolTip property controls the message that will be displayed when the player's Mouse hovers over the Tool in their Backpack.

Generally, the value of this property should describe the what the tool is or its use. For instance, for a shovel tool, you may choose to set the ToolTip to:

Luau
tool.ToolTip = "Shovel"

or

Luau
tool.ToolTip = "Use to dig"

or

Luau
tool.ToolTip = "Shovel - Use to dig"

Methods 2#

ActivateSimulates activation of the Tool.
DeactivateSimulates deactivation of the Tool.

Activate(): ()#

This function simulates activation of the Tool. The tool must be equipped for this function to work.

Returns
  • ()

Deactivate(): ()#

This function simulates deactivation of the Tool. The tool must be equipped for this function to work.

Returns
  • ()

Events 4#

ActivatedFires when the player clicks while the tool is equipped.
DeactivatedFires when the player releases their click while the tool is equipped and activated.
EquippedFires when the tool is equipped.
UnequippedFires when the tool is unequipped.

Activated()#

This event fires when the player clicks while the Tool is equipped. It is not fired if the Ctrl key is pressed during the click.

This event is typically used to perform an action when the player uses the tool, for instance to launch a rocket from a rocket launcher weapon tool.

The below code, when placed in a LocalScript, creates a tool in the local player's Backpack and prints "Tool activated" when the player clicks while the created tool is equipped.

Deactivated()#

This event fires when the player releases their click while the Tool is equipped and activated. It is typically used to perform an action when the player stops using a tool.

The below code, when placed in a LocalScript, creates a tool in the local player's Backpack and prints "Tool deactivated" when the player releases their click while the tool is equipped and activated.

Equipped(mouse: Mouse)#

This event fires when a player equips the Tool (takes it out of their Backpack).

The opposite of this event, Tool.Unequipped, can be used to determine when the player unequips the tool by putting it in their backpack.

Note that this event does not fire when Tool.RequiresHandle is enabled and no handle is present.

NameTypeDefaultDescription
mouseMouseThe player's mouse.

Unequipped()#

This event fires when a player unequips the Tool (puts it in their Backpack).

The opposite of this event, Tool.Equipped, can be used to determine when the player equips the tool by taking it out of their backpack.

Note that this event does not fire when Tool.RequiresHandle is enabled and no handle is present.

Inherited members#

Inherited from BackpackItem 2
Properties (2)

TextureContent, TextureId

Inherited from Model 26
Inherited from PVInstance 4
Properties (2)

Origin, Pivot Offset

Methods (2)

GetPivot, PivotTo

Inherited from Instance 58
Inherited from Object 6
Properties (2)

ClassName, className

Events (1)

Changed

Subclasses 1#