Adding a muzzle flash?

I have a question, well, I need help at the same time.
I have been trying to add a muzzle flash to the tip of my weapon, but nothing worked so far.
One of the difficult part to is ( I guess it is different ) is that I am using a CS:S weapon.

Here is what I have tried so far:
[lua]local Muzzle = EffectData()
Muzzle:SetEntity(self.Weapon)
Muzzle:SetOrigin(self.Owner:GetShootPos())
Muzzle:SetNormal(self.Owner:GetAimVector())
Muzzle:SetAttachment(self.Weapon:GetAttachment( 1 ))
util.Effect( “MuzzleEffect”, Muzzle )[/lua]

But it is appearing where my head is and stays relative to the world ( angles ).

May someone help? Thank you.

You have to place the origin at the muzzle flash attachment point of the weapon’s model.

Origin is expecting a Vector, not an attachment

[editline]22:30[/editline] If you wanna see my code, ask me

An attachment has a specific position which you can get. That’s your vector right there. :smile:
Also maybe you should be a little bit more patient.

I would be more patient but I tried everything I could and nothing works.
I also did try what you said using;
[lua]Muzzle:SetOrigin(self.Weapon:GetAttachment( 1 ))[/lua]
Since, like you said, it is expected to return the Vector and the Angle from the attachment.
But still again. Nothing. The effect is at my head, angles relative to world.
Thanks alot for helping tho, I appreciate.

Like the wiki page of **[Entity.GetAttachment

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetAttachment)** tells us, this function returns an AngPos table. Therefore the position would be self:GetAttachment(1).Pos :smile:

Example usage :
http://luabin.foszor.com/code/gamemodes/sandbox/entities/entities/gmod_turret/init.lua#147

:eng101:

I think we are getting closer to the point.
The angles works. The position tho is something else.
Unfortunatly, It gets the attachment of the owner, but I guess it’s something that should be easy to fix.

Thanks alot