-- Driver Input Loop --

while script.Parent ~= nil do
	--Update throttle, steer, handbrake
	getInputValues()

	local currentVel = Chassis.GetAverageVelocity()

	if Car:GetAttribute("Fuel") > 0 and Car:GetAttribute("Health") > 0 then
		local steer = script.Steering.Value
		Chassis.UpdateSteering(steer, currentVel)

		-- Taking care of throttling
		local throttle = script.Throttle.Value
		script.AngularMotorVelocity.Value = currentVel
		script.ForwardVelocity.Value = DriverSeat.CFrame.LookVector:Dot(DriverSeat.Velocity)
		Chassis.UpdateThrottle(currentVel, throttle)

		-- Taking care of handbrake
		if script.HandBrake.Value > 0 then
			Chassis.EnableHandbrake()
		end
	else
		script.AngularMotorVelocity.Value = 0
		script.ForwardVelocity.Value = 0
		Chassis.UpdateThrottle(0, 0)
	end
	
	task.wait()
end
