How to start trace from a gun to target?

I’m trying to use a tracer effect from the gun’s vector to where ever I shoot

How is this done?

local tr = ply:GetEyeTrace()

I did that earlier, it shoots from the center of my screen.

All weapons shoot from center of your screen.

Ok. So, i’ll have to play with the vector.

I think you can use
local tr = util.QuickTrace(ply:GetShootPos(), ply:GetAimVector())

I don’t think I can get the gun’s position from there.

I’m trying this method, but LookupAttachment() keeps returning 0.

Try the “muzzle” attachment. IIRC that generally emits from the tip of the gun.

Try attachment id 1. Not every model has “muzzle” or “flash” attachments.

I tried muzzle and get the ID ‘1’.

It seems to shoot from below the eye’s view.

The muzzle in the world and the muzzle on the view model are different. Muzzle effects usually take into account whether they are being shown to the local player or on another player, and use the viewmodel muzzle when its the local player.

[editline]12th May 2014[/editline]

Automerge pls:

The quickest example I could google up was this