How to detect if a player has a tool equipped

So what I’m trying to do is create a universal tool display UI on the player’s screen that whenever they equip a tool, will display with the tools corresponding information. Now what I’m wondering is if there is any to detect if a player has a tool equipped without creating a local script in the tool with the tool.equipped. (Essentially it would work so the player could equip any tool and a singular script would recognize that a player has an equipped one of their tools, and then grabs its information.) ?

5 Likes

No method of the Humanoid for this. Use ChildAdded on the parent of the Humanoid and check if the passed argument is of the Tool class.

5 Likes

I just wanted to make what @colbert2677 is saying more clear. Whenever a tool is equipped it is parented to the character model, vice versa when its removed,so all you need to use is the child added function in combination with the IsA() function to verify if a tool is equipped, here is how you can do it from local script:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
Character.ChildAdded:Connect(function(NewChild)
   if NewChild:IsA("Tool") then
   --a new tool is equipped
    --NewChild is the tool equipped
   end
end)
--then to detect if the tool is unequipped you do the opposite
Character.ChildRemoved:Connect(function(RemovedChild)
   if RemovedChild:IsA("Tool") then
   --the tool is unequipped
   --RemovedChild is the tool unequipped
   end
end)

Hence, no there is not a humanoid event to detect whenever a tool is equipped,but you could always make your own.

34 Likes