Script doesn't loop through all children

I’m trying to make a script that loops through all the children looking for a tool and if there is a tool then delete it but the script only loops through everything else except the tool when the tool is inside the player.

cooldown = true
event = game.ReplicatedStorage.Events:WaitForChild("Delivered")
local crate

script.Parent.Touched:Connect(function(part)
	
	if part.Name == "RightFoot" then
		for _, item in pairs(part.Parent:GetChildren()) do
			print(item.Name)
			if item.Name == "Large Crate" then
				item:Destroy()
				print("aaaa")
			end
			
			if item.Name == "Small Crate" then
				item:Destroy()
				print("aaaa")
			end
			
			if item.Name == "Medium Crate" then
				item:Destroy()
				print("aaaa")
			end
		end
	end
end)

Is the player holding the tool?
If not the tool is in their backpack, not their character.

If you want to check for every single children inside a model or (Whatever u would like)
Use GetDescendants

1 Like

Use elseif statements instead of several if statements. That’s probably why it’s not working.

if part.Name == "RightFoot" then

I believe that this line of code is your problem. The player’s right foot won’t always be the player’s character’s part that touches your part.

I will make sure to try that out.