Want to make a SWEP create a beam effect.

I have a SWEP I’ve made, and want to make it create a beam that everyone can see ( not only the weapon user ) between shootpos and trace hitpos.
How would I have to do it?
I only know that you would either have to use render.DrawBeam() or env_beam/env_laser, but I don’t know where to go from there. Can anyone give me a pointer/an article/code/any help whatsoever?
EDIT: This is my current code. It does not work, however.


local bpos1 = ents.Create("info_target")
			bpos1:SetPos(self.Owner:GetShootPos())
			
			bpos1:SetKeyValue("target","BeamPos1")
			bpos1:SetKeyValue("globalname","BeamPos1")
			bpos1:SetName("BeamPos1")
			bpos1:Spawn()
			local bpos2 = ents.Create("info_target")
			bpos2:SetPos(tr.HitPos)
			print(tr.HitPos)
			
			bpos2:SetKeyValue("target","BeamPos2")
			bpos2:SetKeyValue("globalname","BeamPos2")
			bpos2:SetName("BeamPos2")
			bpos2:Spawn()
			local beam = ents.Create("env_beam")
			beam:SetPos(Vector(0,0,0))
			beam:SetKeyValue("LightningStart","BeamPos1")
			beam:SetKeyValue("LightningEnd","BeamPos2")
			beam:SetKeyValue("texture","sprites/laserbeam.spr")
			beam:SetKeyValue("life","5")
			beam:Spawn()