Collision problems

Hi is there any way this collision problem can be fixed. I have tried to set the weapon only to detect parts that their transparency are exactly 0 but i think that fixes nothing.
[robloxapp-20201106-2115004_Trim.wmv|attachment]Imgur: The magic of the Internet

Here is my Code:
clonedweapon.Touched:Connect(function(hit)
if hit:IsA(“BasePart”) and hit.Transparency <= 0 and not hit:IsDescendantOf(char) and not hit:IsDescendantOf(clonedweapon) then
clonedweapon.Anchored = true
touched = true
if hit.Parent:FindFirstChild(“Humanoid”) then
local randomsound = (script.KnifeHitSounds:GetChildren()[math.random(1,#script.KnifeHitSounds:GetChildren())]):Clone()
randomsound.Parent = hit.Parent.HumanoidRootPart
randomsound:Play()
hit.Parent.Humanoid.Health = 0
Debris:AddItem(randomsound,1)
end
end
end)

You didn’t really explain what you’re trying to find out.

I’m guessing you have invisible walls and you don’t want them to have knifes collide with them? Presumably because you said transparency filtering didn’t work.

Have you tried using print() to see what exactly the knife is hitting?

print(hit.Name)

It could be working, maybe just in some places better than others.
Anchoring a fast part on a touched-event is bound to have some slightly buggy results.

What you said is exactly what i am trying to figure out. Maybe i will take as the solution to add a wait() before anchoring the knife at its place.

Solution would probably be to use raycasting.
Raycast for a wall, then align to it. But that’s if you know how to do that.

Or do what I said and see if it’s actually colliding with the invisible wall or not.

Or… add a wait(), messy, but sure.