Shoud Collide

hook.Add(“ShouldCollide”, “policeShouldCollide”, function(ent1, ent2)
if IsValid(ent1) and IsValid(ent2) then
if ent1:IsPlayer() and ent2:GetClass() == “police_shield_door” then
if ent1:isCP() then
if ent1:isArrested() then return end

			return false
		elseif not then
			return false
	elseif ent2:IsPlayer() and ent1:GetClass() == "police_shield_door" then
		if ent2:isCP() then
			if ent2:isArrested() then return end
			return false
		elseif not then
			return false


The code above will let police be able to go through a police shield door anytime, but blocks other players if the shield is active. After some time, this code breaks and every prop/player starts to bounce around the map. Someone has a solution?

Oh my that catacomb of nested logic! Haha.

How do you know this is the script that is breaking?
If it is creating errors you need to save the error output and show which line is breaking specifically.

As players/props don’t start to bounce after some time if this code is commented out. No errors serverside nor clientside.

I really don’t have the slightest clue currently, but at least you get a bump!

This is really making me dread hooking ShouldCollide, even though I may potentially need it. So far I have just been using collision groups, but I don’t think they are as configurable.

Good luck I hope you get to the bottom of your earthquake mystery, this seems like a tricky one if you don’t get any errors and it only happens after some amount of time passes.

I wonder if it is actually time related, or until something specific happens like a force field is deleted or something of that nature.

Anything that can add to your scope or things you can eliminate and test can help point you closer and closer to your elusive problem.

I think it was resolved by using this code:

It did but I expanded on it slightly to support all collision groups. You need to call it every time your function might return something different than it was returning the last frame. In your case that would be calling this on the entity when it’s created, when the entity changes its active state, on a player whenever they change from cp to non-cp, whenever they change from non-cp to cp, and whenever a player changes their arrested state.

function meta:CollisionRulesChanged()
if not self.m_OldCollisionGroup then self.m_OldCollisionGroup = self:GetCollisionGroup() end
self.m_OldCollisionGroup = nil

Thank you guys.

Marked as solved.