PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

EquipTool

This function makes the Humanoid equip the given Tool.

The below example would cause a Player to equip a tool in Workspace named ‘Tool’.


local Players = game:GetService("Players")

local player = Players:FindFirstChildOfClass(“Player”)
if player and player.Character then
	local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
	if humanoid then
		local tool = workspace:FindFirstChild("Tool")
		if tool then
			humanoid:EquipTool(tool)	
		end
	end
end

When this function is called, the humanoid will automatically unequip any Tool|Tools that it currently has equipped

Although they will be equipped, Tool|Tools for which Tool/RequiresHandle is true will not function if they have no handle, regardless if this function is used to equip them or not

See also

  • To unequip tools, use Humanoid/UnequipTools

Parameters

Name Type Default Description

The Tool to equip

Returns

Return Type Summary

No return


Code Samples


Creating a Colorful Brick Tool

The code below creates a new tool and places into the Players/LocalPlayer's Player/Backpack. Then, the code equips the tool for the player user Humanoid/EquipTool.

When the tool is equipped and the player uses it (e.g. pressed their mouse button in-game), the code spawns a new BasePart|part at the position of the click using the Humanoid/TargetPoint position. The code also sets several of the part’s properties, such as giving it a random BasePart/BrickColor.