There are multiple parts in a model called 'Sword' and I want to print the part it touches when the Touched Function is fired. It does do this however it prints it multiple times and this is not what I want. So how do I make the Touched function only fire once instead of multiple times?
Output as the touch function is repeatedly fired: Output
for _, Parts in pairs (Sword:GetChildren()) do
Parts.Touched:connect(function(part)
print(part)
end)
end

4 comments
Debounce?
The goal of that script does not necessarily equate to whether or not the person touched the script, Try using a simply event + anon function. Ex: script.Parent.Touched:connect(function(player) if(player:FindFirstChild("Humanoid") ~= nil) then print(player) end end) -- Make sure the script is inside of the part if you do this script
There must be a better way of doing this. You can weld a part around the sword and listen to that part instead. If this is a tool, you can also listen to the equipped event instead of the touched event since tools are automatically equipped after touching them.
My sword has a really odd shape and is really big so a big part wouldnt work, it'll just fling me around.