How to allow NPC's to hold tools


The title is basically the explanation how would I allow for NPC’s to hold tools.

1 Like

humanoid instances have a method called ‘EquipTool’. you can use this to make the npc equip and use tools.
the following code bit is an example.

local npc = script.Parent
local personoid = npc.Humanoid
local classic_sword = game.ReplicatedStorage.ClassicSword -- as an example, you can use any tool

personoid:EquipTool(classic_sword) -- makes humanoid equip tool

while task.wait(math.random(3,6)) do
	classic_sword:Activate() -- this makes the npc activate the tool
end

do you have any idea on how i’d go about this, like should i detect when the tool gets touched and then equip it to the NPC or detect when the NPC touches a tool and equip that tool

if you wanted to do it that way, i’d see if the tool is parented to the workspace, check for the largest object in the tool, and if that object is touched by the npc, then make the npc equip that tool.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.