I have tried to make a script that detects whether or not a player has a tool with a certain in their inventory or not. It finds the correct tool and activates the function, but the issue is it also searches for tools that have a different name and then activates both functions at once. I realise this is probably because of the GetChildren, so is there any way I can get a script to stop searching for the tool when it finds it?
for _, tool in pairs(player.Backpack:GetChildren()) do
if tool.Name == "key6" and debounce == false then
if isOpen == false then open() else close() end
elseif tool.Name ~= "key6" and debounce == false then
debounce = true
script.Parent.deny:Play()
debounce = false
end
end
thank you in advance