How to make teleporting SWEP in GMod?

So… How to make SWEP that teleports you to place where you aim?

Using self.Owner:SetPos(self.Owner:GetEyeTrace().HitPos)

I made a very simple tool for it ages ago (although this isn’t a SWEP)-



TOOL.Category = "Poser"
TOOL.Name = "#Teleporter"
TOOL.Command = nil
TOOL.ConfigName = ''

if CLIENT then

language.Add("tool.stupidteleporter.name", "Teleporting Tool")
language.Add("tool.stupidteleporter.desc", "Teleports yourself")
language.Add("tool.stupidteleporter.0", "Left click to teleport. Right click does nothing.")

end

function TOOL:LeftClick( trace )
	self:GetOwner():SetPos(trace.HitPos)
	return true
end

function TOOL:RightClick( trace )
	return false
end


Note you might get stuck in walls and stuff since all it does is set a position without checking anything. It goes in ‘lua\weapons\gmod_tool\stools’