Spawn A Entity On Gun Shot?

EDIT:As is the case with many of my problems, this one has been solved.
Basically, ents.Create("–Entity name here–") can be used without fault, however, the entity you are trying to spawn needs to be arranged correctly. Beforehand, I was using a single .lua file, seperating server, client and shared code using if statements within. However, ents.Create only recognises the sent you are trying to spawn if it has a shared, cl_init and init lua file in a folder with the name of the sent you are spawning.
YAY! Learning!

I am trying to make a weapon that uses an entity (not just a prop) as a bullet.
I was wondering, how would one spawn an entity, already made by me, as a result of firing my weapon?

Weapon:


//AT Rifle
if SERVER then

AddCSLuaFile("shared.lua")

SWEP.AutoSwitchFrom = true
SWEP.AutoSwitchTo = true
SWEP.Weight = 5

elseif CLIENT then

SWEP.DrawCrosshair = false
SWEP.PrintName = "Anti Tank Rifle"
SWEP.Slot = 4
SWEP.SlotPos = 1

end

SWEP.Author = "Ricool"
SWEP.Category = "Ricool's SWEPs"
SWEP.Spawnable = true
SWEP.ViewModel = "models/weapons/v_crossbow.mdl"
SWEP.WorldModel = "models/weapons/w_crossbow.mdl"
SWEP.HoldType = "ar2"

SWEP.Primary.Ammo = "ar2"
SWEP.Primary.Automatic = false
SWEP.Primary.ClipSize = 8
SWEP.Primary.DefaultClip = 32
SWEP.Primary.Damage = 10000
SWEP.Primary.Force = 1000

SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Automatic = false
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0


local Shootsound = ("weapons/grenade_launcher1.wav")

function SWEP:Initialize()

end

function SWEP:Reload()

self:DefaultReload( ACT_VM_RELOAD )
print("Reload")

end

function SWEP:Think()

//print("Think")

end

function SWEP:PrimaryAttack()

if (self:Clip1() <= 0 ) then return end

print("Attack")

self:TakePrimaryAmmo(1)

local trace = self.Owner:GetEyeTrace()
local eye = self.Owner:GetAimVector()

local SpawnPos = self.Owner:GetShootPos()

local bullet = ents.Create("entities/at_rifle_round")


//



//

end




Entity:


//AT_Rifle_Round
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.Category = "Ricool's SENTS"
ENT.PrintName = "AT_Rifle_Round"
ENT.Author = "Ricool"
ENT.Spawnable = true
ENT.Contact		= "Don't"
ENT.Spawnable		= true
ENT.AdminSpawnable	= false

if SERVER then

	local model = "models/Items/AR2_Grenade.mdl"
	local classname = "at_rifle_round"
	local ShouldSetOwner = true

	function ENT:SpawnFunction( ply, tr )
		if ( !tr.Hit ) then return end
		local SpawnPos = ply:GetShootPos()
		local ent = ents.Create( classname )
		ent:SetPos( SpawnPos )
		ent:SetAngles(ply:EyeAngles())
		ent:Spawn()
		ent:Activate()
		if ShouldSetOwner then
			ent.Owner = ply
		end
		return ent
	
	end

	function ENT:Initialize()
	
		self.Entity:SetModel(model)
		self.Entity:PhysicsInit(SOLID_VPHYSICS)
		self.Entity:SetMoveType(MOVETYPE_VPHYSICS)
		self.Entity:SetSolid(SOLID_VPHYSICS)
		local phys = self.Entity:GetPhysicsObject()
		
		if (phys:IsValid()) then
			phys:Wake()
		end
		
		phys:SetVelocity(self:GetForward()*1000000)
		
	end
	
elseif CLIENT then

	function ENT:Initialize()
	
		self.Color = Color( 255, 255, 255, 255 )
	
	end

	function ENT:Draw()
	
		--self:DrawEntityOutline( 1 )
		self.Entity:DrawModel()

	end

end


I don’t think this really deserves a whole thread but I read that this subforum is about to undergo a few changes and from what I understood, this is the best place to post it right now.
Thanks in advance!

EDIT: To be more specific, I am referring to how GDCW weapons work, by spawning entities.