Vehicle Spawining Help

Hello firstly im a complete newb with lua so dont get mad at me :smiley: i do have experiance with other languages so im not a complete noob to coding.
any way my problem is im trying to fix up an old Gmod Racer game mode i have updated most of the syntax to the latest versions but im having trouble fixing the function that spawns the cars it crashes my server saying
Vehicle <> unable to properly initialize due to script error in <scripts/vehicles/gmracer_0.txt>!
now i have looked at gmracer_0.txt and i cannot see any errors but so i was wondering if anyone can help me fix this
sorry for the huge ammount of code i cant narrow it down any further

vehicle spawn code:



function PlayerMetaTable:SpawnJeep ( Location, Angles )
	local IsSpawning = false

	if self.IsSpawning then return false end
	
	self.IsSpawning = true
	
	if !SERVER then return false end
	if GAMEMODE.PlayerVehicles[self] and GAMEMODE.PlayerVehicles[self]:IsValid() then GAMEMODE.PlayerVehicles[self]:Remove() end

	local JeepTable = self:CompileJeepData()
	
	local SaveFile = GAMEMODE.DefaultJeep
	
	local SaveFile = string.gsub(SaveFile, "&VEHICLEWEIGHT&", JeepTable.Weight)
	local SaveFile = string.gsub(SaveFile, "&HORSEPOWER&", JeepTable.Horsepower)
	local SaveFile = string.gsub(SaveFile, "&MAXFORWARDSPEED&", JeepTable.ForwardMaximumMPH)
	local SaveFile = string.gsub(SaveFile, "&MAXREVERSESPEED&", JeepTable.ReverseMaximumMPH)
	local SaveFile = string.gsub(SaveFile, "&AUTOBRAKEMAXSPEED&", JeepTable.AutobrakeMaximumSpeed)
	local SaveFile = string.gsub(SaveFile, "&BOOSTFORCE&", JeepTable.BoostForce)
	local SaveFile = string.gsub(SaveFile, "&BOOSTDURATION&", JeepTable.BoostDuration)
	local SaveFile = string.gsub(SaveFile, "&BOOSTDELAY&", JeepTable.BoostDelay)
	local SaveFile = string.gsub(SaveFile, "&BOOSTMAXSPEED&", JeepTable.BoostMaximumSpeed)
	local SaveFile = string.gsub(SaveFile, "&SLOWTURNDEGREE&", JeepTable.TurningDegrees_Slow)
	local SaveFile = string.gsub(SaveFile, "&FASTTURNDEGREE&", JeepTable.TurningDegrees_Fast)
	local SaveFile = string.gsub(SaveFile, "&BOOSTTURNDEGREE&", JeepTable.TurningDegrees_Boost)
	local SaveFile = string.gsub(SaveFile, "&SLOWCARSPEED&", JeepTable.SlowCarSpeed)
	local SaveFile = string.gsub(SaveFile, "&FASTCARSPEED&", JeepTable.FastCarSpeed)
	local SaveFile = string.gsub(SaveFile, "&FORWARDAXILBRAKE&", JeepTable.ForwardAxilBreaking)
	local SaveFile = string.gsub(SaveFile, "&REARAXILBRAKE&", JeepTable.RearAxilBreaking)
	local SaveFile = string.gsub(SaveFile, "&REARCONSTANT&", JeepTable.RearConstant)
	local SaveFile = string.gsub(SaveFile, "&REARDAMPENING&", JeepTable.RearDampening)
	local SaveFile = string.gsub(SaveFile, "&FRONTCONSTANT&", JeepTable.FrontConstant)
	local SaveFile = string.gsub(SaveFile, "&FRONTDAMPENING&", JeepTable.FrontDampening)
	
	if self:GetUsedPart('Engine') >= 5 then
		SaveFile = string.gsub(SaveFile, "&PREFIX&", 'JNK')
	else
		SaveFile = string.gsub(SaveFile, "&PREFIX&", 'ATV')
	end
	
	self:SetHealth(JeepTable.Health)
	file.Write("scripts/vehicles/gmracer_" .. GAMEMODE.NumJeepsPlaced .. ".txt", SaveFile)
		GAMEMODE.PlayerVehicles[self] = ents.Create("prop_vehicle_jeep")
		if !GAMEMODE.PlayerVehicles[self] or !GAMEMODE.PlayerVehicles[self]:IsValid() then
			self:Kill()
			self:PrintMessage(HUD_PRINTTALK, "Sorry, but an error occurred.")
			return false
		end
		
		GAMEMODE.PlayerVehicles[self]:SetKeyValue("vehiclescript", "scripts/vehicles/gmracer_" .. GAMEMODE.NumJeepsPlaced .. ".txt")
		
		local carstyle = self:GetUsedPart( "Car style" ) or 0
		if carstyle == 1 then
			GAMEMODE.PlayerVehicles[self]:SetModel("models/swmodels/swbuggy.mdl")
		else
			GAMEMODE.PlayerVehicles[self]:SetModel("models/swmodels/swoldbuggy.mdl")		
		end

		GAMEMODE.PlayerVehicles[self]:SetPos(Location)
		GAMEMODE.PlayerVehicles[self]:SetAngles(Angles)
		GAMEMODE.PlayerVehicles[self]:Spawn()
		GAMEMODE.PlayerVehicles[self]:SetOwner(self)
				
		
		self:EnterVehicle(GAMEMODE.PlayerVehicles[self])
		
		GAMEMODE.NumJeepsPlaced = GAMEMODE.NumJeepsPlaced + 1
		GAMEMODE.PlayerVehicles[self].Children = {}
		
		if GAMEMODE.SpawnCarParts then
			local DoTime = 0
			for k, v in pairs(GAMEMODE.PartsTable) do
				if self and GAMEMODE.PlayerVehicles[self] and GAMEMODE.PlayerVehicles[self]:IsValid() and v[self:GetUsedPart(k)] then
				
					local Forward = GAMEMODE.PlayerVehicles[self]:GetForward() // left
					local Back = Forward * -1  // right
					local Right = GAMEMODE.PlayerVehicles[self]:GetRight() // back
					local Left = Right * -1 // Forward
					local Up = GAMEMODE.PlayerVehicles[self]:GetUp() // Up
					local Down = Up * -1 // Down
								
					local Ent = v[self:GetUsedPart(k)].Place(GAMEMODE.PlayerVehicles[self], Forward, Back, Right, Left, Up, Down)
					for k, p in pairs(Ent) do
						p:SetOwner(self)
						table.insert(GAMEMODE.PlayerVehicles[self].Children, p)
					end
				end
			end
		else
			self:PrintMessage(HUD_PRINTTALK, "The admin has chosen to not spawn models for your car parts. This may be temporary to help stabalize the server.")
		end
		GAMEMODE.PlayerTables[self].LastNOSTime = 0
		
		self:GetTable().PlayerVehicleBak = GAMEMODE.PlayerVehicles[self]
		self.IsSpawning = false
		
		constraint.Weld(self:GetVehicle(), game.GetWorld(), 0, 0, 0, false)	
end


the code that the vehicle script is generated from:



GM.DefaultJeep = [[
"vehicle"
{
	"wheelsperaxle"	"2"
	"body"
	{
		"countertorquefactor"	"0.9"
		"massCenterOverride"	"0 -30 12"
		"massoverride"			"&VEHICLEWEIGHT&"
		"addgravity"			"1"
		"maxAngularVelocity"	"720"
	}
	"engine"
	{
		"horsepower"		"&HORSEPOWER&"
		"maxrpm"		"6500"
		"maxspeed"		"&MAXFORWARDSPEED&"
		"maxReverseSpeed"	"&MAXREVERSESPEED&"
		"autobrakeSpeedGain"	"&AUTOBRAKEMAXSPEED&"
		"autobrakeSpeedFactor"	"3.0"
		"autotransmission"	"1"
		"axleratio"		"4.56"
		"gear"			"3.2"
		"gear"			"2.4"
		"gear"			"1.5"
		"gear"			"1.0"
		"gear"			"0.84"
		"shiftuprpm"		"5400"
		"shiftdownrpm"		"2000"

		"boost"
		{
			"force"		"&BOOSTFORCE&"
			"duration"	"&BOOSTDURATION&"
			"delay"		"&BOOSTDELAY&"
			"torqueboost"	"1"
			"maxspeed"	"&BOOSTMAXSPEED&"
		}
	}
	"steering"
	{
		"degreesSlow"		"&SLOWTURNDEGREE&"
		"degreesFast"		"&FASTTURNDEGREE&"
		"degreesBoost"		"&BOOSTTURNDEGREE&"
		"steeringExponent"	"1.4"
		"slowcarspeed"		"&SLOWCARSPEED&"
		"fastcarspeed"		"&FASTCARSPEED&"
		"slowSteeringRate"	"4.0"		
		"fastSteeringRate"	"2.0"
		"steeringRestRateSlow"	"4.0"
		"steeringRestRateFast"	"2.0"
		"turnThrottleReduceSlow" "0.01"
		"turnThrottleReduceFast" "2.0"
		"brakeSteeringRateFactor"	"6"
		"throttleSteeringRestRateFactor"	"2"
		"boostSteeringRestRateFactor"	"1.7"
		"boostSteeringRateFactor"	"1.7"

		"powerSlideAccel"	"250"

		"skidallowed"		"1"
		"dustcloud"		"0"

	}

	"axle"
	{
		"wheel"
		{
			"radius"	"18"
			"mass"		"100"
			"damping"	"0"
			"rotdamping"	"0.0"
			"material"	"jeeptire"
			"skidmaterial"	"slidingrubbertire"
			"brakematerial" "brakingrubbertire"
		}
		"suspension"
		{
			"springConstant"		"&FRONTCONSTANT&"
			"springDamping"			"&FRONTDAMPENING&"
			"stabilizerConstant"		"20"
			"springDampingCompression"	"9"
			"maxBodyForce"			"9"
		}

		"torquefactor"	"0.5"
		"brakefactor"	"&FORWARDAXILBRAKE&"
	}

	"axle"
	{
		"wheel"
		{
			"radius"	"22"
			"mass"		"100"
			"damping"	"0"
			"rotdamping"	"0.0"
			"material"	"jeeptire"
			"skidmaterial"	"slidingrubbertire"
			"brakematerial" "brakingrubbertire"
		}
		"suspension"
		{
			"springConstant"		"&REARCONSTANT&"
			"springDamping"			"&REARDAMPENING&"
			"stabilizerConstant"		"20"
			"springDampingCompression"	"9"
			"maxBodyForce"			"9"
		}
		"torquefactor"	"0.5"
		"brakefactor"	"&REARAXILBRAKE&"
	}
}

"vehicle_sounds"
{
	"gear"
	{
		"max_speed"		"0.27"
		"speed_approach_factor" "1.0"
	}

	"gear"
	{
		"max_speed"		"0.5"
		"speed_approach_factor" "0.05"
	}
	"gear"
	{
		"max_speed"		"0.75"
		"speed_approach_factor" "0.052"
	}
	"gear"
	{
		"max_speed"		"0.95"
		"speed_approach_factor" "0.034"
	}
	"gear"
	{
		"max_speed"		"1.5"
		"speed_approach_factor" "0.033"
	}
	"gear"
	{
		"max_speed"		"2.0"
		"speed_approach_factor" "0.03"
	}
	"state"
	{
		"name"		"SS_START_WATER"
		"sound"		"ATV_start_in_water"
	}

	"state"
	{
		"name"		"SS_START_IDLE"
		"sound"		"&PREFIX&_engine_start"
		"min_time"	"4.0"
	}
	"state"
	{
		"name"		"SS_SHUTDOWN_WATER"
		"sound"		"ATV_stall_in_water"
	}
	"state"
	{
		"name"		"SS_IDLE"
		"sound"		"&PREFIX&_engine_idle"
	}
	"state"
	{
		"name"		"SS_REVERSE"
		"sound"		"&PREFIX&_reverse"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_0"
		"sound"		"&PREFIX&_rev"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_0_RESUME"
		"sound"		"&PREFIX&_engine_idle"
		"min_time"	"0.75"
	}
	"state"
	{
		"name"		"SS_GEAR_1"
		"sound"		"&PREFIX&_firstgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_1_RESUME"
		"sound"		"&PREFIX&_firstgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_2"
		"sound"		"&PREFIX&_secondgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_2_RESUME"
		"sound"		"&PREFIX&_secondgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_3"
		"sound"		"&PREFIX&_thirdgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_3_RESUME"
		"sound"		"&PREFIX&_thirdgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_4"
		"sound"		"&PREFIX&_fourthgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_4_RESUME"
		"sound"		"&PREFIX&_fourthgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_SLOWDOWN_HIGHSPEED"
		"sound"		"&PREFIX&_throttleoff_fastspeed"
		"min_time"	"2.0"
	}
	"state"
	{
		"name"		"SS_SLOWDOWN"
		"sound"		"&PREFIX&_throttleoff_slowspeed"
		"min_time"	"2.0"
	}
	"state"
	{
		"name"		"SS_TURBO"
		"sound"		"&PREFIX&_turbo_on"
		"min_time"	"2.5"
	}
	"state"
	{
		"name"		"SS_SHUTDOWN"
		"sound"		"ATV_engine_stop"
	}
	"crashsound"
	{
		"min_speed"			"350"
		"min_speed_change"	"250"
		"sound"				"ATV_impact_medium"
		"gear_limit"		"1"
	}
	"crashsound"
	{
		"min_speed"			"450"
		"min_speed_change"	"350"
		"sound"				"ATV_impact_heavy"
	}

	
	"skid_lowfriction"		"&PREFIX&_skid_lowfriction"
	"skid_normalfriction"		"&PREFIX&_skid_normalfriction"
	"skid_highfriction"		"&PREFIX&_skid_highfriction"
}
]];


and finally gmracer_0.txt



"vehicle"
{
	"wheelsperaxle"	"2"
	"body"
	{
		"countertorquefactor"	"0.9"
		"massCenterOverride"	"0 -30 12"
		"massoverride"			"1200"
		"addgravity"			"1"
		"maxAngularVelocity"	"720"
	}
	"engine"
	{
		"horsepower"		"300"
		"maxrpm"		"6500"
		"maxspeed"		"30"
		"maxReverseSpeed"	"15"
		"autobrakeSpeedGain"	"1"
		"autobrakeSpeedFactor"	"3.0"
		"autotransmission"	"1"
		"axleratio"		"4.56"
		"gear"			"3.2"
		"gear"			"2.4"
		"gear"			"1.5"
		"gear"			"1.0"
		"gear"			"0.84"
		"shiftuprpm"		"5400"
		"shiftdownrpm"		"2000"

		"boost"
		{
			"force"		"1"
			"duration"	"0.5"
			"delay"		"10"
			"torqueboost"	"1"
			"maxspeed"	"30"
		}
	}
	"steering"
	{
		"degreesSlow"		"50"
		"degreesFast"		"18"
		"degreesBoost"		"12.5"
		"steeringExponent"	"1.4"
		"slowcarspeed"		"12.857142857143"
		"fastcarspeed"		"17.142857142857"
		"slowSteeringRate"	"4.0"		
		"fastSteeringRate"	"2.0"
		"steeringRestRateSlow"	"4.0"
		"steeringRestRateFast"	"2.0"
		"turnThrottleReduceSlow" "0.01"
		"turnThrottleReduceFast" "2.0"
		"brakeSteeringRateFactor"	"6"
		"throttleSteeringRestRateFactor"	"2"
		"boostSteeringRestRateFactor"	"1.7"
		"boostSteeringRateFactor"	"1.7"

		"powerSlideAccel"	"250"

		"skidallowed"		"1"
		"dustcloud"		"0"

	}

	"axle"
	{
		"wheel"
		{
			"radius"	"18"
			"mass"		"100"
			"damping"	"0"
			"rotdamping"	"0.0"
			"material"	"jeeptire"
			"skidmaterial"	"slidingrubbertire"
			"brakematerial" "brakingrubbertire"
		}
		"suspension"
		{
			"springConstant"		"80"
			"springDamping"			"1"
			"stabilizerConstant"		"20"
			"springDampingCompression"	"9"
			"maxBodyForce"			"9"
		}

		"torquefactor"	"0.5"
		"brakefactor"	"0.2"
	}

	"axle"
	{
		"wheel"
		{
			"radius"	"22"
			"mass"		"100"
			"damping"	"0"
			"rotdamping"	"0.0"
			"material"	"jeeptire"
			"skidmaterial"	"slidingrubbertire"
			"brakematerial" "brakingrubbertire"
		}
		"suspension"
		{
			"springConstant"		"80"
			"springDamping"			"1"
			"stabilizerConstant"		"20"
			"springDampingCompression"	"9"
			"maxBodyForce"			"9"
		}
		"torquefactor"	"0.5"
		"brakefactor"	"0.4"
	}
}

"vehicle_sounds"
{
	"gear"
	{
		"max_speed"		"0.27"
		"speed_approach_factor" "1.0"
	}

	"gear"
	{
		"max_speed"		"0.5"
		"speed_approach_factor" "0.05"
	}
	"gear"
	{
		"max_speed"		"0.75"
		"speed_approach_factor" "0.052"
	}
	"gear"
	{
		"max_speed"		"0.95"
		"speed_approach_factor" "0.034"
	}
	"gear"
	{
		"max_speed"		"1.5"
		"speed_approach_factor" "0.033"
	}
	"gear"
	{
		"max_speed"		"2.0"
		"speed_approach_factor" "0.03"
	}
	"state"
	{
		"name"		"SS_START_WATER"
		"sound"		"ATV_start_in_water"
	}

	"state"
	{
		"name"		"SS_START_IDLE"
		"sound"		"ATV_engine_start"
		"min_time"	"4.0"
	}
	"state"
	{
		"name"		"SS_SHUTDOWN_WATER"
		"sound"		"ATV_stall_in_water"
	}
	"state"
	{
		"name"		"SS_IDLE"
		"sound"		"ATV_engine_idle"
	}
	"state"
	{
		"name"		"SS_REVERSE"
		"sound"		"ATV_reverse"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_0"
		"sound"		"ATV_rev"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_0_RESUME"
		"sound"		"ATV_engine_idle"
		"min_time"	"0.75"
	}
	"state"
	{
		"name"		"SS_GEAR_1"
		"sound"		"ATV_firstgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_1_RESUME"
		"sound"		"ATV_firstgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_2"
		"sound"		"ATV_secondgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_2_RESUME"
		"sound"		"ATV_secondgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_3"
		"sound"		"ATV_thirdgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_3_RESUME"
		"sound"		"ATV_thirdgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_4"
		"sound"		"ATV_fourthgear"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_GEAR_4_RESUME"
		"sound"		"ATV_fourthgear_noshift"
		"min_time"	"0.5"
	}
	"state"
	{
		"name"		"SS_SLOWDOWN_HIGHSPEED"
		"sound"		"ATV_throttleoff_fastspeed"
		"min_time"	"2.0"
	}
	"state"
	{
		"name"		"SS_SLOWDOWN"
		"sound"		"ATV_throttleoff_slowspeed"
		"min_time"	"2.0"
	}
	"state"
	{
		"name"		"SS_TURBO"
		"sound"		"ATV_turbo_on"
		"min_time"	"2.5"
	}
	"state"
	{
		"name"		"SS_SHUTDOWN"
		"sound"		"ATV_engine_stop"
	}
	"crashsound"
	{
		"min_speed"			"350"
		"min_speed_change"	"250"
		"sound"				"ATV_impact_medium"
		"gear_limit"		"1"
	}
	"crashsound"
	{
		"min_speed"			"450"
		"min_speed_change"	"350"
		"sound"				"ATV_impact_heavy"
	}

	
	"skid_lowfriction"		"ATV_skid_lowfriction"
	"skid_normalfriction"		"ATV_skid_normalfriction"
	"skid_highfriction"		"ATV_skid_highfriction"
}