- 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
- What is the issue?
I’m 100 % sure that my way of calculating the orientation is the worst …
- 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 !!!