Codectionary / Developer documentation / Luau

Tools and equipped behaviour

A Tool moves between a player’s Backpack and character when equipped. Activated is an input signal, not proof that a hit or purchase occurred. Separate the local presentation from any server action, and release temporary UI or connections when the tool is unequipped.

Syntax

tool.Activated:Connect(function()
    print("Tool activated")
end)

Examples

Make an editing practice tool

Create a Tool named Notebook in StarterPack and set RequiresHandle to false. Add this LocalScript inside it. Equip it during Play, then click or tap to print a local message. No remote action is performed.

local tool = script.Parent
assert(tool:IsA("Tool"))
local equipped = false
tool.Equipped:Connect(function() equipped = true end)
tool.Unequipped:Connect(function() equipped = false end)
tool.Activated:Connect(function()
    if equipped then print("Open the local notebook") end
end)

Check equipment from server state

Script in ServerScriptService. This inspects existing players once, so run it while testing or adapt it to an actual server action. A Tool must be in the player’s current character to count as equipped.

local Players = game:GetService("Players")
local function hasNotebookEquipped(player): boolean
    local character = player.Character
    local tool = character and character:FindFirstChild("Notebook")
    return tool ~= nil and tool:IsA("Tool")
end
for _, player in Players:GetPlayers() do
    print(player.Name, hasNotebookEquipped(player))
end

Best practices

  • If RequiresHandle is true, supply the expected Handle part; otherwise the tool may not behave as intended.
  • Do not install another Activated listener every time Equipped fires.
  • For damage or inventory changes, validate ownership, cooldown and target on the server; a client Tool callback is only intent.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading