-- Driver Input Loop --

coroutine.wrap(function()
	while script.Parent ~= nil do
		--Update throttle, steer, handbrake
		local seatedHumanoid = DriverSeat.Occupant
		if seatedHumanoid and not Util.isPlayerBot(Players:GetPlayerFromCharacter(seatedHumanoid.Parent)) then
			getInputValues()
		
			local currentVel = Chassis.GetAverageVelocity()
		
			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
		end
		wait()
	end
end)()
