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

CarStartupSound:Play()
delay(0.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 * 0.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)
