Prop Spawner SWEP

A SWEP where a ghost is put where you aim, and when you leftclick, it spawns it.
That’s all I need.

Now, before you say ‘Duplicator tool,’ this is for a gamemode which doesn’t use the tool gun at all.

Here’s my shitty attempt (I’m sure you can make it better!)
The problem with it is that nothing in the function DoGhost runs serverside, meaning the ghost is not created.

[lua]
function SWEP:SetupDataTables()
self:DTVar(“Entity”, 0, “Player”)
end

if SERVER then
AddCSLuaFile(“shared.lua”)
SWEP.Weight = 1
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = false

end
SWEP.player = nil
if CLIENT then
SWEP.PrintName = “Prop Spawner”
SWEP.DrawCrosshair = true
SWEP.DrawAmmo = false
SWEP.ViewModelFOV = 60
SWEP.ViewModelFlip = false
SWEP.CSMuzzleFlashes = false
SWEP.Slot = 1
SWEP:SetDTEntity(“Player”,LocalPlayer())
end

SWEP.ViewModel = “models/weapons/v_physcannon.mdl”
SWEP.WorldModel = “models/weapons/w_physcannon.mdl”
local prop = nil

function SWEP:Think()
if SERVER then
DoGhost(self:GetDTEntity(“Player”),prop)
end
end

function DoGhost(ply,prop)
if (not prop or prop == “”) then return end
print(ply:Nick())
local pos = ply:GetShootPos()
local ang = ply:GetAimVector()
local td = {}
td.start = pos
td.endpos = pos+(ang*200)
td.filter = ply
td.mask = SOLID_BRUSHONLY
local s = util.TraceLine(td).HitPos
if(s == nil) then return end

local ang = ply:EyeAngles()
ang.yaw = ang.yaw + 180
if MODELS[prop].ANG then ang.yaw = ang.yaw + MODELS[prop].ANG.yaw end

s:Add(Vector(0,0,-2))
if(ply.GhostProp == nil or not ply.GhostProp:IsValid()) then
	local ent = ents.Create("ghost")
	
	ent:SetPos(s)
	ent:SetAngle(ang)
	
	ent:SetModel(prop)
	ent:Spawn()
	ent:GetPhysicsObject():EnableMotion(false)     
	r,g,b,a = ent:GetColor()
	ent:SetColor(r,g,b,150)
	ply.GhostProp = ent
else
	ply.GhostProp:SetPos(s)
	ply.GhostProp:SetAngle(ang)
	print("POS : "..ply.GhostProp:GetPos().."

")
end
end

function GhostCC(player,command,args)
prop = args[1]
DoGhost(SWEP:GetDTEntity(“Player”),prop)
end
concommand.Add(“GhostStart”,GhostCC)
[/lua]

Good luck, and danke sehr.