HingeConstraint set as Servo randomly spinning back and forth

So, I’m creating a MTB (mountain bike) chassis, and I’m currently on the steering portion. Right now I have two parts connected w/ attachments to make a servo. The servo’s target angle is set based on a VehicleSeat’s Steer value. -1 being -12 degrees, and 1 being 12 degrees.

Now: it usually works fine; but - on occasions - it will start moving between -12 degrees and 12 degrees back and forth without any input from the player or script. Does anyone know anything I can do to prevent this?

The steering function
function SteerChanged()
	if Seat.Steer == 1 then
		Servo.TargetAngle = -TurnAngle
		Lean.Torque = Vector3.new(0,0,LeanTorque)
	elseif Seat.Steer ==  -1 then
		Servo.TargetAngle = TurnAngle
		Lean.Torque = Vector3.new(0,0,-LeanTorque)
	else
		Servo.TargetAngle = 0
		Lean.Torque = Vector3.new(0,0,0)
	end
end

I have tried messing with debounces, wait(), and the Lean Torque constraint.

Thanks, -sansprosii

After tons of research and struggling; I realised the answer was in plain sight all along: TweenService. I made the hinge completely static and unmovable, and used TweenService to rotate the Attachment0.

So if anybody has a similar issue; remember TweenService is the answer.

1 Like