How to find out if a player is holding a weapon

I was wondering how i would go about making a script to wait until a tool is in my player.Character

I have already tried using .Equipped, but that makes the function fire when the tool is in his inventory, i want to check if the player has the tool in his hands

Character:FindFirstChild(“Tool”)

You could do this which is more reliable. Add this into a local script. Then move the local script into starter gui(if u don’t then this wont work.)

local Character = game.Players.LocalPlayer.Character
Character.ChildAdded:Connect(function(Child)
	if Child:IsA("Tool") then
		if Child.Name == "ToolNameHere" then
			--- do stuff
		end
	end
end)


This will check every time a child is added. So it’ll check if it is a tool. Then it will check if it’s your desired tool name. Then you can make it do the stuff.

1 Like

Thanks a lot! ive been trying to figure this out I really appreciate it! :grinning:

1 Like

Haha, no problem! Have a good day!

1 Like

The Equipped event is fired every time the player equips a new tool, I think that would be better to use since it has less impact on the server.

https://developer.roblox.com/en-us/api-reference/event/Tool/Equipped

He said he has already tried to use .equipped but he wanted to check if the player has the tool in their hands.

1 Like
local players = game:GetService("Players")

player.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local backpack = player:WaitForChild("Backpack")
		local tools = backpack:GetChildren()
		for i, tool in pairs(tools) do
			tool.Equipped:Connect(function(mouse)
				--do stuff here
			end)
		end
	end)
end)

That is exactly what equipped is for. Your script is just checking the backpack of the player.

I know. But he said he wanted to use something esle thats not .Equipped.

Equipped is only fired when the tool is equipped not when the tool is simply in the player’s backpack.

I think the OP wanted to detect when any Tool instance was given to the player, not a specific one.

Reply: Yeah, but that’s not your fault.

I’m not sure their post is a little misleading and they seem to be conflating equipped with inventory.