I have found that rotating parts, and particularly models, can be troublesome at times. Especially when you want to do rotations above 180* going in a specific direction, or a 360 degree rotation. I know that in my experience, the amount of code it takes to take care of all of that is a little frustrating. It’s not a huge amount, but it’s enough to where we should change that.
Introducing, the rotation module. With this module, you can simply call :rotateItem(instance,propertyTable) and customize it as much as you’d like. Certainly helps to clean and speed things up a bit, especially if you’re doing a lot of them!
Below is an example usage. Note that you do not need to define all properties, as they will default to the values that are below.
local module = require(workspace.rotationHandler)
module:rotateItem(workspace.Car,{
["rotationDegrees"] = 360 , -- The amount you want the object to be rotated.
["rotationAxis"] = "Y", -- The axis to rotate.
["rotationTime"] = 5, -- The amount of time one full rotation takes to complete.
["rotationCondition"] = function() return 1000000 end, -- Conditional statement/countdown. For countdowns, this is your timer. Otherwise, your conditional statement goes here.
["rotationConditionType"] = "countdown", -- Set this to 'countdown' if you want it to end on a timer. For infinite rotation, just put it at a high value.
["reverseWhenFinished"] = false, -- Whether the object reverses back to it's starting position at the end of each rotation.
["easingStyle"] = Enum.EasingStyle.Linear,
["easingDirection"] = Enum.EasingDirection.In
}