Reference API Roblox

Engine API

Website

Related

Reference API Roblox

Tool

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

Member index 17

HistoryMember
731CanBeDropped: bool
731Enabled: bool
731Grip: CFrame
731ManualActivationOnly: bool
731RequiresHandle: bool
486ToolTip: string
573Activate(): null
573Deactivate(): null
462Activated()
462Deactivated()
483Equipped(mouse: Mouse)
462Unequipped()
inherited from BackpackItem
731TextureContent: Content
731TextureId: ContentId
inherited from Model
731LevelOfDetail: ModelLevelOfDetail
731ModelStreamingMode: ModelStreamingMode
731PrimaryPart: BasePart
731Scale: float
731WorldPivot: CFrame
573AddPersistentPlayer(playerInstance: Player = Player): null
573BreakJoints(): null
607GetBoundingBox(): (CFrame, Vector3)
462GetExtentsSize(): Vector3
731GetModelCFrame(): CFrame
731GetModelSize(): Vector3
648GetPersistentPlayers(): Instances
731GetPrimaryPartCFrame(): CFrame
562GetScale(): float
573MakeJoints(): null
573MoveTo(position: Vector3): null
573RemovePersistentPlayer(playerInstance: Player = Player): null
731ResetOrientationToIdentity(): null
573ScaleTo(newScaleFactor: float): null
731SetIdentityOrientation(): null
731SetPrimaryPartCFrame(cframe: CFrame): null
573TranslateBy(delta: Vector3): null
731breakJoints(): null
731makeJoints(): null
731move(location: Vector3): null
731moveTo(location: Vector3): null
inherited from PVInstance
731Origin: CFrame
731Pivot Offset: CFrame
576GetPivot(): CFrame
573PivotTo(targetCFrame: CFrame): null
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

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.

History 94

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.

History 3

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
10
11
local Players = game:GetService("Players")

local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.Parent = Players.LocalPlayer.Backpack

function onActivation()
	print("Tool activated")
end

tool.Activated:Connect(onActivation)

History 2

CanBeDropped

TypeDefault
booltrue

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.

History 6

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.

History 3

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
10
11
local Players = game:GetService("Players")

local tool = Instance.new("Tool")
tool.RequiresHandle = false
tool.Parent = Players.LocalPlayer.Backpack

function toolDeactivated()
	print("Tool deactivated")
end

tool.Deactivated:Connect(toolDeactivated)

History 2

Enabled

TypeDefault
booltrue

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.

History 6

Equipped

Parameters (1)
mouseMouse

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.

History 3

Grip

TypeDefault
CFrame0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1

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.

History 10

  • 731 Change Default of Grip from to CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  • 726 Change Default of Grip from CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) to
  • 705 Change Default of Grip from to CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  • 705 Change Default of Grip from CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1) to
  • 702 Change Default of Grip from to CFrame(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  • 553 Change Default of Grip from to
  • 550 Change Category of Grip from Appearance to Transform
  • 486 Change ThreadSafety of Grip from ReadOnly to ReadSafe
  • 462 Change ThreadSafety of Grip from to ReadOnly
  • 61 Add Grip

ManualActivationOnly

TypeDefault
boolfalse

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.

History 6

RequiresHandle

TypeDefault
booltrue

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.

History 6

ToolTip

TypeDefault
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
tool.ToolTip = "Shovel"

or

1
tool.ToolTip = "Use to dig"

or

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

History 3

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.

History 2

Settings