Prop inside of Player

Hello, i’m trying to figure out how to make a prop nocollide with another player if it is frozen inside the player. Once the player is no longer inside the prop, make it solid again.

hook.Add("OnPhysgunFreeze", "Freeze", function(wep, phys, ent, ply)
   if ent:GetClass() == "prop_physics" then
     local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent, ignoreworld = true }
     local tr = util.TraceEntity( trace, ent )
     if ( tr.Hit and tr.Entity.IsPlayer and tr.Entity:IsPlayer()) then
       return false



Could someone assist me?

I’m new to Gmod Lua but let me see if I can gather more information.

First, what is currently happening with this chunk of code? What is your expected output?

Second, this line …

if ( tr.Hit and tr.Entity.IsPlayer and tr.Entity:IsPlayer()) then ...

tr.Entity.IsPlayer and tr.Entity:IsPlayer(), why both? I only see the latter in the docs.

Third, your entity function calls seem to make sense but why are you returning false?

Fourth, you set the render mode to RENDERMODE_TRANSALPHA, but you don’t call Entity:SetColor(Color) afterwards. What’s the point?

I’m not trying to criticize, I just want more information!

I assume he’s checking that function exists before calling it in case something unexpected happens

That will never happen. tr.Entity will always return an entity – NULL:IsPlayer () is even valid. If that’s true, he doesn’t even have to check tr.Hit or if tr.Entity is valid

Everything works as intended to besides the Entity:SetCollisionGroup(). Even if i set it to COLLISION_GROUP_WORLD the prop still remains solid. I could, of course, do ent:Remove() but that could get annoying when building.