Disabling collisions between two instances of the same entity

As the topic title states, I’m trying to get two separate instances of the same entity to not collide.

My current code, in lua\autorun\collisions.lua:

hook.Add("ShouldCollide", "ShouldCollideKnivesHook",
	function(ent1, ent2)
		-- If both entities are knives, but they have different owners, don't collide.
		if (ent1:GetClass() == "sent_proj_sakuyaKnife01" && ent2:GetClass() == "sent_proj_sakuyaKnife01")
			--if (ent1.Owner != ent2.Owner)
				return false

Now, I’ve tried placing this code in an autorun file (as shown above), as well as trying it in the shared.lua and init.lua of the actual entity. But, for some reason, the instances still collide with each other. I’ve been going at this problem for half the day now, and I just can’t figure out what the cause is.

Any help would be greatly appreciated.

I suspect case issue.
I suggest that you rename your entity to sent_proj_sakuyaknife01, I’ve never seen anyone use capitals in their entity class names, and it’s not really recommendable.

Make sure the code is reading you properly :

(ent1:GetClass() == “sent_proj_sakuyaKnife01”) && (ent2:GetClass() == “sent_proj_sakuyaKnife01”)

That worked.

Thanks _Kilburn!

Though, why is it that capital letters do that?

No idea, but a bunch of stuff in the Source engine is automatically turned into lowercase, like models. It took me a while to figure out that I was comparing ent:GetModel() with a model name that had capitals in it.

That is not necessary at all.

No, but I figured it had to be something and in other circumstances it can make a pretty big difference.