CarStartupSound:Play()delay(.5,function()CarEngine:Play()end)for p in pairs(carSettings)do ContextActionService:BindAction(p,Control,false,Enum.KeyCode[p])end local p=false local R=0 Heartbeat:Connect(function(A)p=false for c,e in pairs(carSettings)do if not e[1]then continue end p=true if typeof(e[2])=="\086\101\099\116\111\114\051"then BodyPosition.Position+=(e[2]*A)*R elseif typeof(e[2])=="\110\117\109\098\101\114"then BodyGyro.CFrame*=CFrame.Angles(0,(e[2]*A)*(R*.1),0)elseif typeof(e[2])=="\067\070\114\097\109\101"then BodyPosition.Position+=Vector3.new(((-math.sin(math.rad(CarModel.Orientation.Y))*e[2].X)*A)*R,0,((-math.cos(math.rad(CarModel.Orientation.Y))*e[2].X)*A)*R)end end if p then R=math.clamp(R+accelerationSettings.inc*A,0,accelerationSettings.max);(TweenService:Create(CarEngine,TweenInfo.new(A),{PlaybackSpeed=1+(1*R)/accelerationSettings.max})):Play()else R=0;(TweenService:Create(CarEngine,TweenInfo.new(1),{PlaybackSpeed=1})):Play()end p=false end)


CarStartupSound:Play();
delay(.5, function()
	CarEngine:Play();
end)

for key in pairs(carSettings) do
	ContextActionService:BindAction(key, Control, false, Enum.KeyCode[key])
end

local accelerating = false;
local a = 0;
Heartbeat:Connect(function(dt)
	accelerating = false
	for key, property in pairs(carSettings) do
		if not property[1] then continue end;
		accelerating = true;
		
		if typeof(property[2]) == "Vector3" then
			BodyPosition.Position += property[2]*dt*a;
		elseif typeof(property[2]) == "number" then
			BodyGyro.CFrame *= CFrame.Angles(0, property[2]*dt*(a*.1), 0);
		elseif typeof(property[2]) == "CFrame" then
			BodyPosition.Position += Vector3.new(
				-math.sin(math.rad(CarModel.Orientation.Y))*property[2].X*dt*a,
				0,
				-math.cos(math.rad(CarModel.Orientation.Y))*property[2].X*dt*a
			) -- trig is evil
		end
	end
	
	if accelerating then
		a = math.clamp(a + accelerationSettings.inc*dt, 0, accelerationSettings.max);
		TweenService:Create(CarEngine, TweenInfo.new(dt), {PlaybackSpeed =  1 + (1*a/accelerationSettings.max)}):Play();
	else
		a = 0;
		TweenService:Create(CarEngine, TweenInfo.new(1), {PlaybackSpeed =  1}):Play();
	end
	
	
	
	accelerating = false;
end)
