Problem with rotating model

I am trying to make so a part rotates, then mean it hits its max rotation, rotates back to the min, etc. But instead of it smoothly rotating back to the min, it snaps back.

local model = game.Workspace.Satelite.Satellite
local rotationSpeed = 0.25
wait(1.5)
model.PrimaryPart = model.Primary

local minRotation = -45
local maxRotation = 22.5 
local currentRotation = 0

local function rotateModel()
	currentRotation = currentRotation + rotationSpeed
	if currentRotation > maxRotation then
		currentRotation = minRotation
	elseif currentRotation < minRotation then
		currentRotation = maxRotation
	end

	local newRotation = CFrame.fromEulerAnglesYXZ(0, math.rad(currentRotation), 0)
	local currentPos = model.PrimaryPart.CFrame.Position
	model:SetPrimaryPartCFrame(CFrame.new(currentPos) * newRotation)
end

game:GetService("RunService").Stepped:Connect(function()
	rotateModel()
end)

Instead of setting currentRotation = minRotation or maxRotation if it meets either of those conditions try setting rotationSpeed *= -1 when those conditions are met.

1 Like

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