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)