Tool
An object, such as a weapon, that can be equipped by a Humanoid.
Memory category | PhysicsParts |
---|
Member index 17
Description
Tools are objects that a Humanoid object can equip. For players, they are stored in a Backpack object parented to a Player object. In-game, 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 Part named "Handle" inside (though one isn't required if Tool.RequiresHandle is off). Tools that are to be provided to (re)spawning players ought to be stored in the StarterPack.
On desktop, pressing a number key (1, 2, 3...) will equip a tool. Equipped tools can be dropped into the Workspace by pressing Backspace. It's recommended that you turn Tool.CanBeDropped off so it isn't possible to drop a tool, die, respawn and drop again to duplicate tools. On gamepads, LB and RB buttons will equip tools. You can disable activation via left click (or right trigger on gamepad) by setting Tool.ManualActivationOnly on. Doing so requires that you call Activate yourself through some sort of other user input.
Tools aren't the only way to capture user input. You can also use ContextActionService, UserInputService or Player:GetMouse(). If you need a Tool to have multiple actions, such as pressing a key while the Tool is equipped, you should use ContextActionService's BindAction and UnbindAction in the Equipped and Unequipped events, respectively. Use a LocalScript send these actions to the server via a RemoteFunction inside the Tool.
History 70
- 573 Change ReturnType of Deactivate from void to null
- 573 Change ReturnType of Activate from void to null
- 564 Change MemoryCategory of Tool from Instances to PhysicsParts
- 557 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 557 Change CanLoad of from true to false
- 557 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 557 Change CanLoad of from true to false
- 557 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 557 Change CanLoad of from true to false
- 557 Change Tags of from [NotReplicated] to [Hidden, NotReplicated]
- 557 Change CanLoad of from true to false
- 553 Add
- 553 Change Default of RequiresHandle from to true
- 553 Change Default of ManualActivationOnly from to false
- 553 Change Default of from to Vector3(0, 1, 0)
- 553 Change Default of from to Vector3(1, 0, 0)
- 553 Change Default of from to Vector3(0, 0, 0)
- 553 Change Default of from to Vector3(-0, -0, -1)
- 553 Change Default of Grip from to
- 553 Change Default of Enabled from to true
- 553 Change Default of CanBeDropped from to true
- 550 Change Category of from Appearance to Transform
- 550 Change Category of from Appearance to Transform
- 550 Change Category of from Appearance to Transform
- 550 Change Category of from Appearance to Transform
- 550 Change Category of Grip from Appearance to Transform
- 486 Change ThreadSafety of ToolTip from ReadOnly to ReadSafe
- 486 Change ThreadSafety of RequiresHandle from ReadOnly to ReadSafe
- 486 Change ThreadSafety of ManualActivationOnly from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Grip from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Enabled from ReadOnly to ReadSafe
- 486 Change ThreadSafety of CanBeDropped from ReadOnly to ReadSafe
- 483 Change Parameters of Equipped from (mouse: Instance) to (mouse: Mouse)
- 462 Change ThreadSafety of Unequipped from to Unsafe
- 462 Change ThreadSafety of Equipped from to Unsafe
- 462 Change ThreadSafety of Deactivated from to Unsafe
- 462 Change ThreadSafety of Activated from to Unsafe
- 462 Change ThreadSafety of Deactivate from to Unsafe
- 462 Change ThreadSafety of Activate from to Unsafe
- 462 Change ThreadSafety of ToolTip from to ReadOnly
- 462 Change ThreadSafety of RequiresHandle from to ReadOnly
- 462 Change ThreadSafety of ManualActivationOnly from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of Grip from to ReadOnly
- 462 Change ThreadSafety of Enabled from to ReadOnly
- 462 Change ThreadSafety of CanBeDropped from to ReadOnly
- 295 Add Deactivate
- 209 Add RequiresHandle
- 171 Add ManualActivationOnly
- 168 Add Activate
- 61 Add Grip
- 50 Add ToolTip
- 50 Add CanBeDropped
- 47 Add Unequipped
- 47 Add Equipped
- 47 Add Deactivated
- 47 Add Activated
- 47 Add
- 47 Add
- 47 Add
- 47 Add
- 47 Add Enabled
- 47 Add Tool
Members 17
Activate
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
This function simulates activation of the Tool. The tool must be equipped for this function to work.
Thread safety | Unsafe |
---|
Activated
Parameters (0) | ||
---|---|---|
No parameters. |
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.
1 2 3 4 5 6 7 8 9 |
|
Thread safety | Unsafe |
---|
CanBeDropped
Type | Default | |
---|---|---|
bool | true |
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.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of CanBeDropped from to true
- 486 Change ThreadSafety of CanBeDropped from ReadOnly to ReadSafe
- 462 Change ThreadSafety of CanBeDropped from to ReadOnly
- 50 Add CanBeDropped
Deactivate
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
This function simulates deactivation of the Tool. The tool must be equipped for this function to work.
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of Deactivate from void to null
- 462 Change ThreadSafety of Deactivate from to Unsafe
- 295 Add Deactivate
Deactivated
Parameters (0) | ||
---|---|---|
No parameters. |
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.
1 2 3 4 5 6 7 8 9 |
|
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of Deactivated from to Unsafe
- 47 Add Deactivated
Enabled
Type | Default | |
---|---|---|
bool | true |
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.
Thread safety | ReadSafe |
---|---|
Category | State |
Loaded/Saved | true |
Equipped
Parameters (1) | |
---|---|
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.
Thread safety | Unsafe |
---|
Grip
Type | Default | |
---|---|---|
CFrame |
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.
Thread safety | ReadSafe |
---|---|
Category | Transform |
Loaded/Saved | true |
ManualActivationOnly
Type | Default | |
---|---|---|
bool | false |
The ManualActivationOnly 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.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of ManualActivationOnly from to false
- 486 Change ThreadSafety of ManualActivationOnly from ReadOnly to ReadSafe
- 462 Change ThreadSafety of ManualActivationOnly from to ReadOnly
- 171 Add ManualActivationOnly
RequiresHandle
Type | Default | |
---|---|---|
bool | true |
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.
Thread safety | ReadSafe |
---|---|
Category | Behavior |
Loaded/Saved | true |
History 4
- 553 Change Default of RequiresHandle from to true
- 486 Change ThreadSafety of RequiresHandle from ReadOnly to ReadSafe
- 462 Change ThreadSafety of RequiresHandle from to ReadOnly
- 209 Add RequiresHandle
ToolTip
Type | Default | |
---|---|---|
string |
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:
1
|
|
or
1
|
|
or
1
|
|
Thread safety | ReadSafe |
---|---|
Category | Appearance |
Loaded/Saved | true |
Unequipped
Parameters (0) | ||
---|---|---|
No parameters. |
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.
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of Unequipped from to Unsafe
- 47 Add Unequipped