Need some help about entity collisions

So I made a spectator deathmatch script for TTT. For now it’s working great except that it’s causing the server to crash randomly, I suppose it’s due to ShouldCollide because I enable it on all entities (yes I know it’s bad) :
hook.Add(“OnEntityCreated”, “OnEntityCreated_Ghost”, function(ent)
hook.Add(“ShouldCollide”, “ShouldCollide_Ghost”, function(ent1, ent2)
if ent1:IsPlayer() and (ent1.IsGhost and ent1:IsGhost()) and not (ent2:IsPlayer() and (ent2.IsGhost and ent2:IsGhost())) then
return false
if ent2:IsPlayer() and (ent2.IsGhost and ent2:IsGhost()) and not (ent1:IsPlayer() and (ent1.IsGhost and ent1:IsGhost())) then
return false
So I would like to use a different method or optimise it, any ideas? Setting the collision group to weapons does not seem to work.

hello i need to sleep but could you set their collision group to

ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS )

edit: wait i read a word wrong

leaving this here because im proud of my heritage