I've been making a infection tool that if Q is pressed and the player's head hits the other player, it will remove all of their tools and give them the infection tool. My issue is that I tried seeing if the tool in the player's inventory is equal to "nil". But every time I try to use it, it says that the tool is not a valid member of Backpack. How do I solve this?
local hum = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum and hum.Backpack["infection tool"] == nil then
local c = hum.Backpack:GetChildren()
for i = 1, #c do
c[i]:Remove()
end
wait(0.1)
game.ServerStorage["infection tool"]:Clone().Parent = hum.Backpack
end
This isn't the entire script, but it is the majority of it. It clones perfectly to the player's head for it to work, but the script above is the only code it has right now.

5 comments
There's only one issue, whenever it gets touched, it gives them more than one. Which is the one thing I want to stop. How will I do that?
Try removing the wait(0.1) I don't know if you need it or not, but that's why it's being set more than once.
When the Touch event is activated, the code checks to see if the player has the infect tool, and if the player doesn't, then it waits a tenth of a second and then adds the infect tool. Meanwhile, more touch events can be fired, and since the earlier one is still waiting to add it, the new events will not see any infect tool, and will proceed to add their own infect tool. Also, please try to keep i
Oh, you're referring to my suggestion to use different code.
dont worry, robloxwhiz is just cancer, he gives misinformations 101% of the time so take his opinion with a grain of salt