From 81ec88d84068ba22e2d79af1fd8009fc62a66640 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 27 Jan 2026 02:40:23 +0300 Subject: [PATCH 1/5] Fix #2 Fixes #2 --- lua/weapons/gmod_tool/stools/multi_parent.lua | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lua/weapons/gmod_tool/stools/multi_parent.lua b/lua/weapons/gmod_tool/stools/multi_parent.lua index e35639c..b4eecb6 100644 --- a/lua/weapons/gmod_tool/stools/multi_parent.lua +++ b/lua/weapons/gmod_tool/stools/multi_parent.lua @@ -161,6 +161,19 @@ end function TOOL:LeftClick( trace ) local ent = trace.Entity + -- Hacky way to hit parented entity + if not ent:IsValid() then + local owner = self:GetOwner() + local trace = util.GetPlayerTrace( owner ) + + -- Identical to the toolgun code + trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) + trace.mins = vector_origin + trace.maxs = vector_origin + trace.filter = { owner, owner:GetVehicle() } + ent = util.TraceHull(trace).Entity + end + if ent:IsValid() and ent:IsPlayer() then return end if SERVER and not util.IsValidPhysicsObject( ent, trace.PhysicsBone ) then return false end @@ -252,6 +265,19 @@ function TOOL:RightClick( trace ) local ent = trace.Entity + -- Hacky way to hit parented entity + if not ent:IsValid() then + local owner = self:GetOwner() + local trace = util.GetPlayerTrace( owner ) + + -- Identical to the toolgun code + trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) + trace.mins = vector_origin + trace.maxs = vector_origin + trace.filter = { owner, owner:GetVehicle() } + ent = util.TraceHull(trace).Entity + end + if ent:IsValid() and ent:IsPlayer() then return false end if SERVER and not util.IsValidPhysicsObject( ent, trace.PhysicsBone ) then return false end if ent:IsWorld() then return false end From 1c283be88d634e0a6c8e6da216060b98a3b678b8 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 27 Jan 2026 02:44:44 +0300 Subject: [PATCH 2/5] Check for perms --- lua/weapons/gmod_tool/stools/multi_parent.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/weapons/gmod_tool/stools/multi_parent.lua b/lua/weapons/gmod_tool/stools/multi_parent.lua index b4eecb6..1413ae6 100644 --- a/lua/weapons/gmod_tool/stools/multi_parent.lua +++ b/lua/weapons/gmod_tool/stools/multi_parent.lua @@ -171,7 +171,12 @@ function TOOL:LeftClick( trace ) trace.mins = vector_origin trace.maxs = vector_origin trace.filter = { owner, owner:GetVehicle() } - ent = util.TraceHull(trace).Entity + + local parented_ent = util.TraceHull(trace).Entity + + if parented_ent:IsValid() and self:IsPropOwner(owner, parented_ent) then + ent = parented_ent + end end if ent:IsValid() and ent:IsPlayer() then return end @@ -275,7 +280,12 @@ function TOOL:RightClick( trace ) trace.mins = vector_origin trace.maxs = vector_origin trace.filter = { owner, owner:GetVehicle() } - ent = util.TraceHull(trace).Entity + + local parented_ent = util.TraceHull(trace).Entity + + if parented_ent:IsValid() and self:IsPropOwner(owner, parented_ent) then + ent = parented_ent + end end if ent:IsValid() and ent:IsPlayer() then return false end From 488a54ac6297576b48d8cf575c0c944cca738d62 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 27 Jan 2026 02:47:44 +0300 Subject: [PATCH 3/5] Don't need this --- lua/weapons/gmod_tool/stools/multi_parent.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/weapons/gmod_tool/stools/multi_parent.lua b/lua/weapons/gmod_tool/stools/multi_parent.lua index 1413ae6..c0cbe00 100644 --- a/lua/weapons/gmod_tool/stools/multi_parent.lua +++ b/lua/weapons/gmod_tool/stools/multi_parent.lua @@ -168,8 +168,6 @@ function TOOL:LeftClick( trace ) -- Identical to the toolgun code trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) - trace.mins = vector_origin - trace.maxs = vector_origin trace.filter = { owner, owner:GetVehicle() } local parented_ent = util.TraceHull(trace).Entity @@ -277,8 +275,6 @@ function TOOL:RightClick( trace ) -- Identical to the toolgun code trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) - trace.mins = vector_origin - trace.maxs = vector_origin trace.filter = { owner, owner:GetVehicle() } local parented_ent = util.TraceHull(trace).Entity From 037a4976dfdb907c61b917d070ebed0f172dae13 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 27 Jan 2026 02:52:06 +0300 Subject: [PATCH 4/5] Less code duplication --- lua/weapons/gmod_tool/stools/multi_parent.lua | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/lua/weapons/gmod_tool/stools/multi_parent.lua b/lua/weapons/gmod_tool/stools/multi_parent.lua index c0cbe00..1b18da9 100644 --- a/lua/weapons/gmod_tool/stools/multi_parent.lua +++ b/lua/weapons/gmod_tool/stools/multi_parent.lua @@ -152,13 +152,7 @@ function TOOL:ParentCheck( child, parent ) return true end -local function sendNotification( selected, ply ) - net.Start( "MultiParent_SendNotification" ) - net.WriteUInt( selected, MAX_EDICT_BITS ) - net.Send( ply ) -end - -function TOOL:LeftClick( trace ) +function TOOL:GetParentedEnt(trace) local ent = trace.Entity -- Hacky way to hit parented entity @@ -177,6 +171,18 @@ function TOOL:LeftClick( trace ) end end + return ent +end + +local function sendNotification( selected, ply ) + net.Start( "MultiParent_SendNotification" ) + net.WriteUInt( selected, MAX_EDICT_BITS ) + net.Send( ply ) +end + +function TOOL:LeftClick( trace ) + local ent = self:GetParentedEnt(trace) + if ent:IsValid() and ent:IsPlayer() then return end if SERVER and not util.IsValidPhysicsObject( ent, trace.PhysicsBone ) then return false end @@ -266,23 +272,7 @@ function TOOL:RightClick( trace ) return true end - local ent = trace.Entity - - -- Hacky way to hit parented entity - if not ent:IsValid() then - local owner = self:GetOwner() - local trace = util.GetPlayerTrace( owner ) - - -- Identical to the toolgun code - trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) - trace.filter = { owner, owner:GetVehicle() } - - local parented_ent = util.TraceHull(trace).Entity - - if parented_ent:IsValid() and self:IsPropOwner(owner, parented_ent) then - ent = parented_ent - end - end + local ent = self:GetParentedEnt(trace) if ent:IsValid() and ent:IsPlayer() then return false end if SERVER and not util.IsValidPhysicsObject( ent, trace.PhysicsBone ) then return false end From 61c7f45c96a395de6ab07c6164c76de2936832e9 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 27 Jan 2026 02:53:26 +0300 Subject: [PATCH 5/5] It works bad for some reason without it --- lua/weapons/gmod_tool/stools/multi_parent.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/weapons/gmod_tool/stools/multi_parent.lua b/lua/weapons/gmod_tool/stools/multi_parent.lua index 1b18da9..1cf7383 100644 --- a/lua/weapons/gmod_tool/stools/multi_parent.lua +++ b/lua/weapons/gmod_tool/stools/multi_parent.lua @@ -162,6 +162,8 @@ function TOOL:GetParentedEnt(trace) -- Identical to the toolgun code trace.mask = bit.bor(CONTENTS_SOLID, CONTENTS_MOVEABLE, CONTENTS_MONSTER, CONTENTS_WINDOW, CONTENTS_DEBRIS, CONTENTS_GRATE, CONTENTS_AUX) + trace.mins = vector_origin + trace.maxs = vector_origin trace.filter = { owner, owner:GetVehicle() } local parented_ent = util.TraceHull(trace).Entity