How do i tell my part which way to rotate?

Hi! I’ve been trying to rotate my car through tween service. I’ve come accross an issue that I can’t figure out.

When I tell the script what i want the orientation of the car to be, I’ve concluded that the script can CHOOSE if it wants to rotate to that orientation by going clockwise or counterclockwise.

Here is an example of code

local goal2 = {
	Orientation = Vector3.new(0, car.Orientation.Y - 45, 0) 
}

The original orientation of the car is (0,180,0). I’ve asked the car to subtract 45 degrees from 180.

It seems quite simple right? 180 - 45 = 135.

But here is the issue. The script does in fact subtract 45 from 180 to get 135, but then it makes its own decision on whether it will get to that destination by rotating clockwise or counterclockwise.

How do i tell my script which way to rotate?

Also, is rotation and orientation the same thing?

thanks

TweenService will attempt to tween to the nearest number so logically it makes more sense for it to Tween from 180 to 135 rather than going all the way around. If you want to go a different direction, you’ll have to use a different method than just directly tweening to that number. One way of doing this is to tween a separate value that will tell the car which way to rotate then every Heartbeat, update the car’s orientation with that value.

1 Like

Absolutely brilliant! Thank you!

To any future readers, when @wwwaylon09_backup says to tween a separate value, they are referring to a literal instant value (boolValue,IntValue,NumberValue,CFrameValue,etc). I am assuming you can only tween number instances because tweening a boolValue doesn’t seem possible. But who knows, I didn’t even know you could tween a instance value!

1 Like

If you’re curious, there’s a list of tweenable properties on the documentation: TweenService | Documentation - Roblox Creator Hub
It’s not necessarily about which instances you can tween but what properties you can tween. For example, you can tween a part’s transparency and the value of a NumberValue because these are both numbers. You however, cannot tween the collision of a part or the value of a BoolValue because these are both booleans. Happy scripting!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.