Convert number into orientation

  1. What do you want to achieve?

I have a part that i want to rotate from 90 degree every time I press “R”, for this I use a tween so I need to know the last goal orientation of a part to prevent the part from get an orientation like 75 degree cause I want only these values : 0, -90, -180, 90

  1. What is the issue?

I’m 100 % sure that my way of calculating the orientation is the worst …

  1. What solutions have you tried so far?

I’ve finaly found out how to get the new orientation by doing this but I’m 100 % sure that it is the worst way of doing what I’m trying to do …

Code
local NewOrientation = -((360 - (LastOrientation - 90) % 360) % 360) == -270 and 90 or -((360 - (LastOrientation - 90) % 360) % 360)
TweenService:Create(Part, TweenInformation, {["Orientation"] = Vector3.new(0, NewOrientation, 0)}):Play()
LastOrientation = NewOrientation

Thanks you for the replies and have a nice day !!!

1 Like

I finaly figured it out, that was the answer : Orientation = (Orientation + 90) % 360 - 180
Have a nice day !

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