Block To Check If Player Has Tool Equiped

Hello everyone I am working on something that’s like a metal detector for my game it can check if someone has a certain tool in their backpack but if they have it equipped it does not detect it here is my code can someone please help me.

local Tools = {"M9 Berreta","M16","AK47","Knife"}
local sound = script.Sounds
local Sound = script.Sound
local Player = game.Players.LocalPlayer


script.Parent.Parent.invis.Touched:Connect(function(hit)
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

	if Player then
		local found = false

		for i, tool in ipairs(Tools) do
			if Player.Backpack:FindFirstChild(tool) then
				found = true
			end
		end

		if found then
			script.Parent.Parent.Clear.Color = Color3.fromRGB(255, 0, 0)
			if not Sound.IsPlaying then
				Sound:Play()
			end
		else
			script.Parent.Parent.Clear.Color = Color3.fromRGB(0, 255, 0)
			if not sound.IsPlaying then
				sound:Play()
			end
		end
	end
end)
1 Like

Is there any errors? What specifically doesn’t work?

not at all. if you see the else statement the light just turns green and the sound plays

Whenever you equip a tool, it is parented to the player’s character. You can just check to see if it’s there.

Example code:

if Player.Character:FindFirstChild(tool) then
    print("Tool found.")
end