Help with Steering

I need help with steering but it doesn’t rotate.

I’m using a vehicle seat.

RunService.Heartbeat:Connect(function(delta)
	local steer = -VehicleSeat.SteerFloat
	Steer.Value += (steer - Steer.Value) * math.min(delta * RotationSpeed.Value, 1)
	AlignOrientation.CFrame *= CFrame.Angles(0, math.rad(Steer.Value), 0)

	local throttle = VehicleSeat.ThrottleFloat * -10
	AlignOrientation.CFrame = CFrame.Angles(math.rad(throttle), 0, 0)
end)

Its probably from this line:

AlignOrientation.CFrame = CFrame.Angles(math.rad(throttle), 0, 0)
3 Likes

So you’re trying to rotate the entire model?
What are the values of Steer.Value, delta, and RotationSpeed.Value before this section of script so we can understand what the outcome is.

local steer = -VehicleSeat.SteerFloat --So you reverse the value of the Steer float, 1 becomes -1 and -1 becomes 1
-- for this example let's start with 1, so now steer = -1
Steer.Value += (steer - Steer.Value) * math.min(delta * RotationSpeed.Value, 1)

so for example if Steer.Value was 1, then you have 1 += (-1 - 1) which = -1
and if Steer.Value was -1 and steer = 1, then it’s -1 += (-1 - -1) which = 0

It’s hard to understand what the heck you are trying to do here.

Your bottom line is using throttle instead of steer which seems odd.

1 Like

I’m only rotating the hitbox that is welded to other parts.

Steer.Value is a number value that starts at 0 and gradually increases like accelerating a car.
RotationSpeed is the speed to rotate the part. The speed is 15.

My problem is that the part wouldn’t rotate because the throttle line of the code sets the CFrame too.

AlignOrientation.CFrame *= CFrame.Angles(0, math.rad(Steer.Value), 0) -- steer
AlignOrientation.CFrame = CFrame.Angles(math.rad(throttle), 0, 0) -- throttle
2 Likes