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))
endBest 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.
At a glance
- Purpose
- Typed scripting and Roblox development
- File extension
- .luau
- Runs in
- Luau host; Roblox engine examples require Roblox Studio
- Usually used with
- Roblox APIs and Studio
Specifications & further reading
Related Luau documentation
RemoteEvent requests and notifications
RemoteEvent sends a message without waiting for a return value. A client calls FireServer; Roblox supplies the sending Player to OnServerEvent. The server can target one client with FireClient or broadcast with FireAllClients. This example requests a fixed help message, not a reward.Player lifecycle and character spawning
A Player can remain connected while its character is destroyed and replaced. Initialize player state once, and character state on every spawn. Connecting an event alone can miss objects that already exist when a script starts.Server authority, validation and rate limits
A valid-looking remote call can still be an impossible game action. Validate both the shape of a request and whether the sender may perform it now. This example lets a nearby living player request a visual switch; it does not trust a client position, target Instance or reward.Raycasting and hit results
A raycast asks what a line segment intersects. Its direction vector includes the distance to search, not just a unit direction. A miss returns nil; a hit provides an Instance, position and surface normal. Filters determine what the query ignores.
RemoteEvent sends a message without waiting for a return value. A client calls FireServer; Roblox supplies the sending Player to OnServerEvent. The server can target one client with FireClient or broadcast with FireAllClients. This example requests a fixed help message, not a reward.Player lifecycle and character spawning
A Player can remain connected while its character is destroyed and replaced. Initialize player state once, and character state on every spawn. Connecting an event alone can miss objects that already exist when a script starts.Server authority, validation and rate limits
A valid-looking remote call can still be an impossible game action. Validate both the shape of a request and whether the sender may perform it now. This example lets a nearby living player request a visual switch; it does not trust a client position, target Instance or reward.Raycasting and hit results
A raycast asks what a line segment intersects. Its direction vector includes the distance to search, not just a unit direction. A miss returns nil; a hit provides an Instance, position and surface normal. Filters determine what the query ignores.