Making a Tool¶
Tools are items players can pick up, equip, and use.
Setting Up a Tool¶
- Insert a
Toolthen parent it to a playersInventory. - Add a
PartorMeshinside the Tool as the handle. This is what players see in their hand. - Optional. Set the
IconImageproperty so it shows up in the inventory bar.


Equipping and Unequipping¶
These events fire when the player pulls out or puts away the tool:
local tool: Tool = script.Parent
tool.Equipped:Connect(function()
print("Tool equipped!")
end)
tool.Unequipped:Connect(function()
print("Tool put away.")
end)
Activating the Tool¶
Activated fires when the player clicks while holding the tool. Deactivated fires when they release the mouse:
tool.Activated:Connect(function()
print("Swing!")
end)
Client + Server Logic¶
ClientScript (inside the Tool):
local tool = script.Parent
local event = Hidden:WaitChild("ToolEvent")
tool.Activated:Connect(function()
tool:PlayAnimation("Swing")
local msg = NetMessage:New()
msg:AddString("action", "swing")
event:InvokeServer(msg)
end)
ServerScript (in ScriptService):
local event = Hidden:WaitChild("ToolEvent")
event.InvokedServer:Connect(function(sender: Player, msg: NetMessage)
local action = msg:GetString("action")
if action == "swing" then
print(sender.Name .. " swung the tool!")
-- whatever here
end
end)
Mini Project: The Boop Stick¶
A simple tool that pushes a specific part when you click.
- Create a
ToolnamedBoopStick. - Add a
Partinside it for the handle. - Create a
NetworkEventnamedBoopEventinsideHidden. - Place a unanchored
PartnamedTargetin the Environment.
ClientScript (inside BoopStick):
local tool = script.Parent
local event = Hidden:WaitChild("BoopEvent")
tool.Activated:Connect(function()
tool:PlayAnimation("Swing")
local msg = NetMessage:New()
msg:AddString("action", "boop")
event:InvokeServer(msg)
end)
ServerScript (in ScriptService):
local event = Hidden:WaitChild("BoopEvent")
local target = Environment:WaitChild("Target")
event.InvokedServer:Connect(function(sender: Player, msg: NetMessage)
if msg:GetString("action") == "boop" then
target.Velocity = Vector3.New(10, 10, 0)
print("Boop!")
end
end)
Click to send the target flying.
Next: Saving Data with Datastores to keep player progress forever.