function IsValidPlayer(ent) return IsValid(ent) and ent:IsPlayer(); end CEntity.GetEyePos = function(self) if (not IsValidPlayer(self)) then return; end local eyepos = self:GetAbsOrigin(); eyepos.z = eyepos.z + self["m_vecViewOffset[2]"]; return eyepos end CEntity.GetEyeAngles = function(self) if (IsValidPlayer(self)) then return Vector( self.m_angEyeAngles[1], self.m_angEyeAngles[2], 0 ) end end CVector.FaceVectorAngle = function(self, target) if target then local targetAngles = ( target - self ):ToAngles() targetAngles = Vector(targetAngles[1], targetAngles[2], 0) return targetAngles end end ents.GetAllRealPlayers = function() local players = {} for index, ply in pairs(ents.GetAllPlayers()) do if ply:IsRealPlayer() then table.insert( players, ply ) end end return players end function ThunderShot( _, activator, caller ) --rename to whatever you want if activator:IsValid() then --timer.Simple( 0.2, function() --This timer acts as a delay, 0.2 so that it syncs up with the game calculating the melee hit. (If the weapon is a melee weapon ofc) util.StartLagCompensation( activator ) local TraceInfo = { start = activator:GetEyePos(), -- distance = 8192, distance = 1100, angles = activator:GetEyeAngles(), mask = MASK_SHOT, --what does the trace line hit? https://github.com/rafradek/sigsegv-mvm/blob/master/scripts/globals.lua#L132 has a list of them if you need to change it -- filter = ents.GetAllRealPlayers() --do not collide with yourself, or teammates filter = activator } local TraceResult = util.Trace( TraceInfo ) util.FinishLagCompensation( activator ) -- if TraceResult.Hit then local HitPos = TraceResult.HitPos --Particle origin local AngleToPlayer = HitPos:FaceVectorAngle( activator:GetEyePos() ) --Get the angle from the particle origin to the players eye pos, if the particle doesn't face player try replacing this with activator:GetEyeAngles() AngleToPlayer[1] = AngleToPlayer[1] + 90 --wrenchmotron_teleport_beam --spell_lightningball_hit_blue local particle = ents.CreateWithKeys( "info_particle_system", { ["effect_name"] = "wrenchmotron_teleport_beam", --Replace "Particle Name" With the particle of your choice, You might need to use PrecacheParticle in the popfile ["start_active"] = 1, ["origin"] = HitPos[1] .. " " .. HitPos[2] .. " " .. HitPos[3], ["angles"] = AngleToPlayer[1] .. " " .. AngleToPlayer[2] .. " " .. AngleToPlayer[3], -- ["cpoint1"] = activator }, true, true) particle.m_hControlPointEnts[1] = activator particle:Teleport( HitPos, AngleToPlayer ) timer.Simple( 0.1, function() particle:Remove() end) -- end --end) end end