Melee infinite range

Hello there, so the other person who is with me in this problem had asked this in the wrong sub-forum so I am posting it in here now.
So basically what our problem is is that we have a melee weapon that works until you hit a shoot through wall, if you hit a shoot through wall you get infinite range with the melee weapon
The original code is this


if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
	
end

if ( CLIENT ) then

	SWEP.PrintName			= "Salmon"			
	SWEP.Author				= "The Mafia Boss"
        
	SWEP.Slot				= 1
	SWEP.SlotPos			= 1
	SWEP.IconLetter			= "f"
	SWEP.DrawCrosshair		= false
	
        killicon.AddFont( "weapon_crowbar", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )


end

-----------------------Main functions----------------------------
 
-- function SWEP:Reload() --To do when reloading
-- end 
 
function SWEP:Think() -- Called every frame
end

function SWEP:Initialize()
end
 
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire(CurTime() + 0.5)

local trace = self.Owner:GetEyeTrace()

if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	bullet = {}
	bullet.Num    = 1
	bullet.Src    = self.Owner:GetShootPos()
	bullet.Dir    = self.Owner:GetAimVector()
	bullet.Spread = Vector(0, 0, 0)
	bullet.Tracer = 0
	bullet.Force  = 30
	bullet.Damage = 38
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
util.PrecacheSound("weapons/unarmed/hit_1.wav")
self.Weapon:EmitSound("weapons/unarmed/hit_1.wav")
else
    util.PrecacheSound("weapons/unarmed/Fists_Fire1.wav")
	self.Weapon:EmitSound("weapons/unarmed/Fists_Fire1.wav")
	self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end

end
 
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire(CurTime() + 1.2)

local trace = self.Owner:GetEyeTrace()

if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
	bullet = {}
	bullet.Num    = 1
	bullet.Src    = self.Owner:GetShootPos()
	bullet.Dir    = self.Owner:GetAimVector()
	bullet.Spread = Vector(0, 0, 0)
	bullet.Tracer = 0
	bullet.Force  = 53
	bullet.Damage = 85
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
util.PrecacheSound("weapons/unarmed/hit_2.wav")
self.Weapon:EmitSound("weapons/unarmed/hit_2.wav")
else
    util.PrecacheSound("weapons/unarmed/unarmed_fire.wav")
	self.Weapon:EmitSound("weapons/unarmed/unarmed_fire.wav")
	self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end

end


function SWEP:Initialize()
self:SetWeaponHoldType("melee")  
end 


-------------------------------------------------------------------

------------General Swep Info---------------
SWEP.Author   = "The Mafia Boss"
SWEP.Contact        = ""
SWEP.Purpose        = "For comic relief, by whacking someone with a freakin' fish."
SWEP.Instructions   = "left click to smack someone, left click to smack them even harder!"
SWEP.Spawnable      = true
SWEP.AdminSpawnable  = true
-----------------------------------------------

------------Models---------------------------
SWEP.ViewModel      = "models/weapons/v_knife_f.mdl"
SWEP.WorldModel   = "models/weapons/w_knife_f.mdl"
-----------------------------------------------

-------------Primary Fire Attributes----------------------------------------
SWEP.Primary.Delay			= 0.5 	
SWEP.Primary.Recoil			= 0		
SWEP.Primary.Damage			= 5	
SWEP.Primary.NumShots		= 1		
SWEP.Primary.Cone			= 0 	
SWEP.Primary.ClipSize		= -1	
SWEP.Primary.DefaultClip	= -1	
SWEP.Primary.Automatic   	= true	
SWEP.Primary.Ammo         	= "none"	
-------------End Primary Fire Attributes------------------------------------
 
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay		= 1.2
SWEP.Secondary.Recoil		= 0
SWEP.Secondary.Damage		= 0
SWEP.Secondary.NumShots		= 1
SWEP.Secondary.Cone			= 0
SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic   	= true
SWEP.Secondary.Ammo         = "none"
-------------End Secondary Fire Attributes--------------------------------

--// File Generated By Fox-Warrior's Resources Generator Version 2.05 \\--

if (SERVER) then
	resource.AddFile( "sound/weapons/knife/knife_deploy1.wav" )
	resource.AddFile( "sound/weapons/knife/knife_slash1.wav" )
	resource.AddFile( "sound/weapons/knife/knife_slash2.wav" )
	resource.AddFile( "models/weapons/v_knife_f.mdl" )
	resource.AddFile( "models/weapons/w_knife_cf.mdl" )
	resource.AddFile( "models/weapons/w_knife_f.mdl" )
	resource.AddFile( "materials/models/weapons/v_models/fish/salmon.vtf" )
	resource.AddFile( "materials/models/weapons/v_models/fish/trout.vmt" )
	resource.AddFile( "materials/models/weapons/v_models/fish/trout.vtf" )
end

I did not create this myself if you are wondering

Here is the issue as I explained on your other post as well (please don’t double post problems)

Your trace is an eye trace to get where you are looking. If the player is looking at something within 75 of it then it will allow a bullet to be created. The problem with this is that the bullet does not come directly from the same position as your EyeTrace therefor it’s possible for EyeTrace to register that the distance to a wall is 0 yet the bullet is created on the other side.

There is no check removing the bullet after a certain distance…this is the same as any bullet in a weapon except it only fires within a certain range.

you did say it was in the wrong place so I posted it in here. anyways it has been resolved.