Tools are a simple way to manage items that the player can hold in their hand and use in-game. They can range from weapons such as swords to food items.
In this course, you’ll learn how to create a tool in the shape of a laser blaster that will play sound effects when equipped or activated.
Creating the Tool
Tool object is the basis of any tool in Roblox, so you’ll need to create one. It’s easier to change how tools look by adding objects such as Parts and MeshParts to the tool in the workspace where they are visible.
- Insert a Tool into the workspace and name it Blaster.
- Insert a
MeshPartinto the tool.
- Set the MeshId property to rbxassetid://92656610.
- Set the TextureId property to rbxassetid://92658105
- The tool needs a part named Handle for the player to hold. Change the name of the MeshPart to Handle.
Storing the Tool
Tools can be kept in the game world as collectable tools or given to all players as starter tools.
The blaster is currently a child of Workspace so it will be collectable. A player can pick up the tool by touching it, causing it to become a child of the character model; the tool will then be equipped and placed in their hotbar.
Understanding the Backpack
During gameplay, unequipped tools are stored within the player’s hierarchy in the Backpack and then moved to their character model when equipped. Any tool that becomes a child of a character will be automatically equipped.
Storing a tool in
StarterPack will place it in a player’s
Backpack when they join the game or respawn.
- Move the Blaster to StarterPack in the Explorer.
- Play the game to test the tool. Click on the hotbar at the bottom of the screen or press 1 on the keyboard to equip the tool.
Position / Orientation
A tool’s position and orientation can be changed using the grip properties. GripPos changes the position of the grip, whereas GripForward, GripRight and GripUp affect the rotation.
Currently the player is holding the center of the blaster instead of the grip.
- Set the GripPos property of the tool to 0, -0.4, 1.1.
- Click the Play button to test the tool.
Notice how the tool is now being gripped in a different position.
By default, the tool name will be displayed on the hotbar icon. It’s good practice to change the icon to be an image of the tool.
- Set the TextureId property of the tool to rbxassetid://92628145.
A tooltip is a small text description that appears when the mouse hovers over a tool in the hotbar. They typically include the name of the tool and/or a brief description of its function.
- Change the ToolTip property to Blaster.
Next Page Using Scripts with Tools