Buying Car Not Removing Previous Car.

Hi, so on the NPC Car Dealer I have on my server spawns cars perfectly fine, but I would like to make it so when you spawn a car from him it removes your previous car that you had.
Here is the Car Dealer Code.

cl_init.lua


include( 'shared.lua' )
 
ENT.RenderGroup = RENDERGROUP_BOTH
 
function ENT:Draw( )
    self.Entity:DrawModel( )
end

function PurchaseCars(  )
local CarFrame = vgui.Create( "DFrame" )
CarFrame:SetPos( ScrW(  ) / 2 - 250,  ScrH(  ) / 2 - 200 )
CarFrame:SetSize( 500, 400 )
CarFrame:SetTitle( "Car Shop" )
CarFrame:SetVisible( true )
CarFrame:SetDraggable( false )
CarFrame:MakePopup(  )
CarFrame:MakePopup()
CarFrame.Paint = function()
	draw.RoundedBox( 8, 0, 0, CarFrame:GetWide(), CarFrame:GetTall(), Color( 0, 0, 0, 200 ) )
end
 


if !CarFrame.Open then 
CarFrame:MoveTo(ScrW() / 2 - 250,  ScrH() / 2 - 200, 1.6, 0,1)
end


local CarTabs = vgui.Create( "DPropertySheet" )
CarTabs:SetParent( CarFrame )
CarTabs:SetPos( 10, 30 )
CarTabs:SetSize( 480, 360 )

local CarList1 = vgui.Create("DPanelList")
CarList1:SetSize(475, 355)
CarList1:SetPos(5, 15)
CarList1:SetSpacing(5)
CarList1:EnableHorizontal(false)
CarList1:EnableVerticalScrollbar(true)

local CarList3 = vgui.Create("DPanelList")
CarList3:SetSize(475, 355)
CarList3:SetPos(5, 15)
CarList3:SetSpacing(5)
CarList3:EnableHorizontal(false)
CarList3:EnableVerticalScrollbar(true)

local CarList = vgui.Create("DPanelList")
CarList:SetSize(475, 355)
CarList:SetPos(5, 15)
CarList:SetSpacing(5)
CarList:EnableHorizontal(false)
CarList:EnableVerticalScrollbar(true)

	local CarPanel = vgui.Create( "DPanel", CarList3 )
	CarPanel:SetSize( 470, 67 )
	local CarButton = vgui.Create( "DButton" )
	CarButton:SetParent( CarPanel )
	CarButton:SetSize( 400, 15 )
	CarButton:SetPos( 67, 52 )
	CarButton:SetText( "Buy a Volvo - Are you sure?" )
	CarButton.DoClick = function ( btn )
    local CarButton = DermaMenu()
    CarButton:AddOption("Yes.", function() RunConsoleCommand("buy_volvo") CarFrame:Close() end )
    CarButton:AddOption("No.", function() end )
	CarButton:Open()
	end
	
	local CarIcon = vgui.Create( "SpawnIcon" )
	CarIcon:SetParent( CarPanel )
	CarIcon:SetPos( 2, 2 )
	CarIcon:SetModel( "models/tdmcars/242turbo.mdl" )
	CarIcon:SetToolTip( nil )
	local CarInfo = vgui.Create( "DLabel" )
	CarInfo:SetText( "$45000" )
	CarInfo:SetParent( CarPanel )
	CarInfo:SetPos( 250, 20 )
    CarList1:AddItem( CarPanel )
	
	
	
	local CarPanel1 = vgui.Create( "DPanel", CarList )
	CarPanel1:SetSize( 470, 67 )
	CarPanel1:SetPos( 67, 202 )
	local CarButton1 = vgui.Create( "DButton" )
	CarButton1:SetParent( CarPanel1 )
	CarButton1:SetSize( 400, 15 )
	CarButton1:SetPos( 67, 52 )
	CarButton1:SetText( "Buy a Golf - Are you sure?" )
	CarButton1.DoClick = function ( btn )
    local CarButton1 = DermaMenu()
    CarButton1:AddOption("Yes.", function() RunConsoleCommand("buy_golf") CarFrame:Close() end )
    CarButton1:AddOption("No.", function() end )
	CarButton1:Open()
	end
	
	local CarIcon1 = vgui.Create( "SpawnIcon" )
	CarIcon1:SetParent( CarPanel1 )
	CarIcon1:SetPos( 2, 2 )
	CarIcon1:SetModel( "models/golf/golf.mdl" )
	CarIcon1:SetToolTip( nil )
	local CarInfo1 = vgui.Create( "DLabel" )
	CarInfo1:SetText( "$50000" )
	CarInfo1:SetParent( CarPanel1 )
	CarInfo1:SetPos( 250, 20 )
    CarList1:AddItem( CarPanel1 )



	
	local CarPanel2 = vgui.Create( "DPanel", CarList3 )
	CarPanel2:SetSize( 470, 67 )
	CarPanel2:SetPos( 67, 404 )
	local CarButton2 = vgui.Create( "DButton" )
	CarButton2:SetParent( CarPanel2 )
	CarButton2:SetSize( 400, 15 )
	CarButton2:SetPos( 67, 52 )
	CarButton2:SetText( "Buy a Corvette - Are you sure?" )
	CarButton2.DoClick = function ( btn )
    local CarButton2 = DermaMenu()
    CarButton2:AddOption("Yes.", function() RunConsoleCommand("buy_corvette") CarFrame:Close() end )
    CarButton2:AddOption("No.", function() end )
	CarButton2:Open()
	end
	
	local CarIcon2 = vgui.Create( "SpawnIcon" )
	CarIcon2:SetParent( CarPanel2 )
	CarIcon2:SetPos( 2, 2 )
	CarIcon2:SetModel( "models/corvette/corvette.mdl" )
	CarIcon2:SetToolTip( nil )
	local CarInfo2 = vgui.Create( "DLabel" )
	CarInfo2:SetText( "$100000" )
	CarInfo2:SetParent( CarPanel2 )
	CarInfo2:SetPos( 250, 20 )
    CarList3:AddItem( CarPanel2 )



	
	local CarPanel3 = vgui.Create( "DPanel", CarList3 )
	CarPanel3:SetSize( 470, 67 )
	CarPanel3:SetPos( 67, 606 )
	local CarButton3 = vgui.Create( "DButton" )
	CarButton3:SetParent( CarPanel3 )
	CarButton3:SetSize( 400, 15 )
	CarButton3:SetPos( 67, 52 )
	CarButton3:SetText( "Buy a Murcielago - Are you sure?" )
	CarButton3.DoClick = function ( btn )
    local CarButton3 = DermaMenu()
    CarButton3:AddOption("Yes.", function() RunConsoleCommand("buy_murcielago") CarFrame:Close() end )
    CarButton3:AddOption("No.", function() end )
	CarButton3:Open()
	end
	
	local CarIcon3 = vgui.Create( "SpawnIcon" )
	CarIcon3:SetParent( CarPanel3 )
	CarIcon3:SetPos( 2, 2 )
	CarIcon3:SetModel( "models/sickness/murcielago.mdl" )
	CarIcon3:SetToolTip( nil )
	local CarInfo3 = vgui.Create( "DLabel" )
	CarInfo3:SetText( "$250000" )
	CarInfo3:SetParent( CarPanel3 )
	CarInfo3:SetPos( 250, 20 )
    CarList3:AddItem( CarPanel3 )
	
	
	

	local CarPanel4 = vgui.Create( "DPanel", CarList1 )
	CarPanel4:SetSize( 470, 67 )
	CarPanel4:SetPos( 67, 606 )
	local CarButton4 = vgui.Create( "DButton" )
	CarButton4:SetParent( CarPanel4 )
	CarButton4:SetSize( 400, 15 )
	CarButton4:SetPos( 67, 52 )
	CarButton4:SetText( "Buy a BMW - Are you sure?" )
	CarButton4.DoClick = function ( btn )
    local CarButton4 = DermaMenu()
    CarButton4:AddOption("Yes.", function() RunConsoleCommand("buy_bmw") CarFrame:Close() end )
    CarButton4:AddOption("No.", function() end )
	CarButton4:Open()
	end
	
	local CarIcon4 = vgui.Create( "SpawnIcon" )
	CarIcon4:SetParent( CarPanel4 )
	CarIcon4:SetPos( 2, 2 )
	CarIcon4:SetModel( "models/sickness/bmw-m5.mdl" )
	CarIcon4:SetToolTip( nil )
	local CarInfo4 = vgui.Create( "DLabel" )
	CarInfo4:SetText( "$55000" )
	CarInfo4:SetParent( CarPanel4 )
	CarInfo4:SetPos( 250, 20 )
    CarList1:AddItem( CarPanel4 )
	
	
	

	local CarPanel5 = vgui.Create( "DPanel", CarList3 )
	CarPanel5:SetSize( 470, 67 )
	CarPanel5:SetPos( 67, 808 )
	local CarButton5 = vgui.Create( "DButton" )
	CarButton5:SetParent( CarPanel5 )
	CarButton5:SetSize( 400, 15 )
	CarButton5:SetPos( 67, 52 )
	CarButton5:SetText( "Buy a Hummer H2 - Are you sure?" )
	CarButton5.DoClick = function ( btn )
    local CarButton5 = DermaMenu()
    CarButton5:AddOption("Yes.", function() RunConsoleCommand("buy_hummer") CarFrame:Close() end )
    CarButton5:AddOption("No.", function() end )
	CarButton5:Open()
	end
	
	local CarIcon5 = vgui.Create( "SpawnIcon" )
	CarIcon5:SetParent( CarPanel5 )
	CarIcon5:SetPos( 2, 2 )
	CarIcon5:SetModel( "models/sickness/hummer-h2.mdl" )
	CarIcon5:SetToolTip( nil )
	local CarInfo5 = vgui.Create( "DLabel" )
	CarInfo5:SetText( "$75000" )
	CarInfo5:SetParent( CarPanel5 )
	CarInfo5:SetPos( 250, 20 )
    CarList3:AddItem( CarPanel5 )
	
	
		local CarPanel7 = vgui.Create( "DPanel", CarList3 )
	CarPanel7:SetSize( 470, 67 )
	CarPanel7:SetPos( 67, 1212 )
	local CarButton7 = vgui.Create( "DButton" )
	CarButton7:SetParent( CarPanel7 )
	CarButton7:SetSize( 400, 15 )
	CarButton7:SetPos( 67, 52 )
	CarButton7:SetText( "Buy a BMW GTR - Are you sure?" )
	CarButton7.DoClick = function ( btn )
    local CarButton7 = DermaMenu()
    CarButton7:AddOption("Yes.", function() RunConsoleCommand("buy_gtr") CarFrame:Close() end )
    CarButton7:AddOption("No.", function() end )
	CarButton7:Open()
	end
	
	local CarIcon7 = vgui.Create( "SpawnIcon" )
	CarIcon7:SetParent( CarPanel7 )
	CarIcon7:SetPos( 2, 2 )
	CarIcon7:SetModel( "models/als/fl/als_fearless_bmw.mdl" )
	CarIcon7:SetToolTip( nil )
	local CarInfo7 = vgui.Create( "DLabel" )
	CarInfo7:SetText( "$100000" )
	CarInfo7:SetParent( CarPanel7 )
	CarInfo7:SetPos( 250, 20 )
    CarList3:AddItem( CarPanel7 )
	
	
CarTabs:AddSheet( "Cheap cars", CarList, "gui/silkicons/group", false, false, "Ugly ones" )
CarTabs:AddSheet( "Normal cars", CarList1, "gui/silkicons/group", false, false, "Normal ones" )
CarTabs:AddSheet( "High priced cars", CarList3, "gui/silkicons/group", false, false, "Smart ones" )
end
usermessage.Hook( "PurchaseCars", PurchaseCars )

init.lua


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( 'shared.lua' )

function ENT:Initialize( )
	self:SetModel( "models/odessa.mdl" )
 	self:SetHullType( HULL_HUMAN )
	self:SetUseType( SIMPLE_USE )
	self:SetHullSizeNormal( )
	self:SetSolid( SOLID_BBOX )
	self:CapabilitiesAdd( CAP_MOVE_GROUND, CAP_OPEN_DOORS, CAP_ANIMATEDFACE, CAP_USE_SHOT_REGULATOR, CAP_TURN_HEAD, CAP_AIM_GUN )
	self:SetMaxYawSpeed( 5000 )
	local PhysAwake = self.Entity:GetPhysicsObject( )
	if PhysAwake:IsValid( ) then
		PhysAwake:Wake( )
	end 
end

function ENT:OnTakeDamage( dmg ) 
	return false
end

function ENT:AcceptInput( name, activator, caller )
    if ( name == "Use" && IsValid( activator ) && activator:IsPlayer( ) ) then
			umsg.Start( "PurchaseCars", activator )
			umsg.End( )
    end
end

local CarVolvoSpawn = { }
CarVolvoSpawn[ 1 ] = Vector(879.933838, -986.696533, -139.968750)



local CarGolfSpawn = { }
CarGolfSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarGolfSpawn[ 2 ] = Vector(3401, 3232, -141)
CarGolfSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarGolfSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarCorvetteSpawn = { }
CarCorvetteSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarCorvetteSpawn[ 2 ] = Vector(3401, 3232, -141)
CarCorvetteSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarCorvetteSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarMurcielagoSpawn = { }
CarMurcielagoSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarMurcielagoSpawn[ 2 ] = Vector(3401, 3232, -141)
CarMurcielagoSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarMurcielagoSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarBMWSpawn = { }
CarBMWSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarBMWSpawn[ 2 ] = Vector(3401, 3232, -141)
CarBMWSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarBMWSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarHummerSpawn = { }
CarHummerSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarHummerSpawn[ 2 ] = Vector(3401, 3232, -141)
CarHummerSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarHummerSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarATVSpawn = { }
CarATVSpawn[ 1 ] = Vector(3521.74, 3185.01, -131.97)
CarATVSpawn[ 2 ] = Vector(3401, 3232, -141)
CarATVSpawn[ 3 ] = Vector(3097.99, 3353.50, -141)
CarATVSpawn[ 4 ] = Vector(2948.20, 3361.57, -131.25)


local CarGtrSpawn = { }
CarGtrSpawn[ 1 ] = Vector(5002.4219,-3550.6282,228.0313)
CarGtrSpawn[ 2 ] = Vector(5002.4219,-3550.6282,228.0313)
CarGtrSpawn[ 3 ] = Vector(5002.4219,-3550.6282,228.0313)
CarGtrSpawn[ 4 ] = Vector(5002.4219,-3550.6282,228.0313)


function SpawnCarVolvo(ply, ent)  
	if not ply:CanAfford(45000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-45000)
	local Volvo = ents.Create("prop_vehicle_jeep")  
	Volvo:SetModel("models/tdmcars/242turbo.mdl")  
	Volvo:SetKeyValue("vehiclescript", "scripts/vehicles/tdmcars/242turbo.txt")  
	Volvo:SetPos(table.Random(CarVolvoSpawn))
	Volvo.Owner =
	Volvo:Own(ply)  
	Volvo:Spawn()  
	Volvo:Activate()
end
end
concommand.Add("buy_volvo", SpawnCarVolvo)


function SpawnCarGolf(ply, ent)  
	if not ply:CanAfford(50000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-50000)
	local golf = ents.Create("prop_vehicle_jeep")  
	golf:SetModel("models/golf/golf.mdl")  
	golf:SetKeyValue("vehiclescript", "scripts/vehicles/golf.txt")  
	golf:SetPos(table.Random(CarGolfSpawn))
	golf.Owner =
	golf:Own(ply)  
	golf:Spawn()  
	golf:Activate()
end
end
concommand.Add("buy_golf", SpawnCarGolf)

function SpawnCarCorvette(ply, ent)  
	if not ply:CanAfford(100000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-100000)
	local Corvette = ents.Create("prop_vehicle_jeep")  
	Corvette:SetModel("models/corvette/corvette.mdl")  
	Corvette:SetKeyValue("vehiclescript", "scripts/vehicles/corvette.txt")  
	Corvette:SetPos(table.Random(CarCorvetteSpawn))
	Corvette.Owner =
	Corvette:Own(ply)  
	Corvette:Spawn()  
	Corvette:Activate()
end
end
concommand.Add("buy_corvette", SpawnCarCorvette)

function SpawnCarMurcielago(ply, ent)  
	if not ply:CanAfford(250000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-250000)
	local Murcielago = ents.Create("prop_vehicle_jeep")  
	Murcielago:SetModel("models/sickness/murcielago.mdl")  
	Murcielago:SetKeyValue("vehiclescript", "scripts/vehicles/murcielago.txt")  
	Murcielago:SetPos(table.Random(CarMurcielagoSpawn))
	Murcielago.Owner =
	Murcielago:Own(ply)  
	Murcielago:Spawn()  
	Murcielago:Activate()
end
end
concommand.Add("buy_murcielago", SpawnCarMurcielago)

function SpawnCarBMW(ply, ent)  
	if not ply:CanAfford(55000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-55000)
	local BMW = ents.Create("prop_vehicle_jeep")  
	BMW:SetModel("models/sickness/bmw-m5.mdl")  
	BMW:SetKeyValue("vehiclescript", "scripts/vehicles/BMW.txt")  
	BMW:SetPos(table.Random(CarBMWSpawn))
	BMW.Owner =
	BMW:Own(ply)  
	BMW:Spawn()  
	BMW:Activate()
end
end
concommand.Add("buy_bmw", SpawnCarBMW)

function SpawnCarHummer(ply, ent)  
	if not ply:CanAfford(75000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-75000)
	local Hummer = ents.Create("prop_vehicle_jeep")  
	Hummer:SetModel("models/sickness/hummer-h2.mdl")  
	Hummer:SetKeyValue("vehiclescript", "scripts/vehicles/hummer.txt")  
	Hummer:SetPos(table.Random(CarHummerSpawn))
	Hummer.Owner =
	Hummer:Own(ply)  	
	Hummer:Spawn()  
	Hummer:Activate()
end
end
concommand.Add("buy_hummer", SpawnCarHummer)

function SpawnCarGtr(ply, ent)  
	if not ply:CanAfford(10000) then  
    Notify(ply, 1, 4, string.format(LANGUAGE.cant_afford, "car"))  return ""  else
	ply:AddMoney(-10000)
	local Gtr = ents.Create("prop_vehicle_jeep_old")  
	Gtr:SetModel("models/als/fl/als_fearless_bmw.mdl")  
	Gtr:SetKeyValue("vehiclescript", "scripts/vehicles/NFSMW_BMW.txt")  
	Gtr:SetPos(table.Random(CarSGtrSpawn))
	Gtr.Owner =
	Gtr:Own(ply)  
	Gtr:Spawn()  
	Gtr:Activate()
end
end
concommand.Add("buy_gtr", SpawnCarGtr)

shared.lua


ENT.Base = "base_ai" 
ENT.Type = "ai"
ENT.PrintName		= ""
ENT.Author			= ""
ENT.Contact			= ""
ENT.Purpose			= ""
ENT.Instructions	= ""
ENT.AutomaticFrameAdvance = true

function ENT:SetAutomaticFrameAdvance( bUsingAnim )
	self.AutomaticFrameAdvance = bUsingAnim
end

CAR_MINI = 1

Any Help Would Be Awesome.
-Thanks

Well, I will tell you how my car npc deletes the old one, anyways since your car dealer has a new function for every new car(bad design imo) you will probably have to add it to every single function, anyways, in my car dealer I do [lua]car:SetName(“car” … ply:UniqueID())[/lua] then, at the top of the function when they spawn a car, I do a [lua]for k, v in pairs (ents.FindByName(“car” … ply:UniqueID())) do
v:Remove()
end[/lua]

Now, I am just giving you the idea on how to do it, you will obviously have to make it work with your script.