-
What do you want to achieve?
Preventing the model to turn less than 30 degrees and greater than 150 degrees at X -
What is the issue?
The model keeps exceeding these two limits. -
What solutions have you tried so far?
Tried using for loops with specific conditions: if currentXOrientation is less than target rotation, then decrease the degree/radians. if it is greater than increase the degree/radians.
Do keep in mind that this model is a child of another model with another primary part.
Edit: Forgot to add that the code below is another attempted solution of mines.
local function rotateMissilesHolder()
local randomRotation = math.random(minRotationXMissilesHolder, maxRotationXMissilesHolder)
local currentMissilesHolderOrientationX = math.floor(MissilesHolderPrimaryPart.Orientation.X)
local rotationDifference = math.rad(randomRotation - currentMissilesHolderOrientationX)
local sign = math.sign(rotationDifference)
local rotationRateChangeWithDirectionRadians = math.rad(sign * rotationRateDegrees)
local rotationChangeCFrame = CFrame.Angles(rotationRateChangeWithDirectionRadians, 0, 0)
local newCFrame
local currentRotationChange = 0
repeat
currentRotationChange += rotationRateChangeWithDirectionRadians
newCFrame = MissilesHolderPrimaryPart.CFrame * rotationChangeCFrame
MissilesHolder:SetPrimaryPartCFrame(newCFrame)
wait(frameRate)
until ((currentRotationChange - rotationDifference) >= 0)
end