Model Tweening Wrong Way

Hi! I’ve tweened a model to rotate and move but the model is rotating the wrong way.
https://gyazo.com/8eecb85e91886a0840421292ebd2eeae

I’d like it to be tweened the OTHER direction. It’s going to the right place, just not the right direction.

The script I’m using is:


local TweenService = game:GetService('TweenService')
local Door = game.Workspace.DoorModelC.Door.BASE
local Opened = workspace.DoorModelC.Open
local Closed = workspace.DoorModelC.Closed

local Open = false
local Close = true


local OpenInfo = TweenInfo.new(
	8,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local OpenGoals = 
	{
		CFrame = Opened.CFrame
	}



local OpenAnimation = TweenService:Create(Door, OpenInfo, OpenGoals)

local ClosedInfo = TweenInfo.new(
	8,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local ClosedGoals = 
	{
		CFrame = Closed.CFrame
	}

local CloseAnimation = TweenService:Create(Door, ClosedInfo, ClosedGoals)



	
		OpenAnimation:Play()





script.Disabled = true


Any support is helpful, tysm!

You should slightly rotate it to the direction you want it to go in before running this. It seems like you’re rotating it 180 degrees so it defaults to the wrong way.

try this :

local TweenService = game:GetService('TweenService')
local Door = game.Workspace.DoorModelC.Door.BASE
local Opened = workspace.DoorModelC.Open
local Closed = workspace.DoorModelC.Closed

local Open = false
local Close = true


local OpenInfo = TweenInfo.new(
	8,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local OpenGoals = 
	{
		CFrame = Opened.CFrame
	}



local OpenAnimation = TweenService:Create(Door, OpenInfo, OpenGoals)

local ClosedInfo = TweenInfo.new(
	8,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.In,
	0,
	false,
	0
)

local ClosedGoals = 
	{
		CFrame = Closed.CFrame
	}

local CloseAnimation = TweenService:Create(Door, ClosedInfo, ClosedGoals)



	
		OpenAnimation:Play()





script.Disabled = false

TweenService will always automatically choose the shortest route to rotate a part where it needs to. There’s unfortunately no way to customize which direction it turns in ( though it’d be nice).

In this case, you’ll have to either do multiple tweens in a row (which would be difficult to keep smooth as I see you’re using the Sine EasingStyle, so if you wanted to compromise and make the EasingStyle Linear instead the smoothness would be retained) or you can use a for loop. If you want maximum smoothness, I recommend RenderStepped like my example below for rotating. If you wanted to switch the direction, just make the y-value in CFrame.Angles negative

local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function(dt)
    Door.CFrame = Door.CFrame * CFrame.Angles(0, math.rad(.1 * dt), 0)
end)

why you disabled the script? it wont work if you disabled

Tween service is still the best option here. alex only needs to update the doors CFrame once before tweening to ensure that the shortest path is the correct one. Put this before OpenAnimation:Play()

Door.CFrame = Door.CFrame * CFrame.Angles(0, math.rad(-1), 0)

no difference, thank you for the help though. I am disabling the script as it disables once the tween has begun and means we can reuse this script etc…

how much adjustment would it need?

The gif for some reason isn’t showing for me so if OP is indeed trying to rotate 180 degrees, I agree your method is the best

1 Like

Yeah, it’s a 180 rotation. I’ll try that method.

I updated my comment with the answer. If -1 degrees doesn’t work, just fiddle with it. Alternatively, just slightly rotate your open or closed part in the direction you want the door to rotate. It doesn’t have to be noticable.

1 Like

Even -4 is having no impact, am I changing the wrong value?

Door.CFrame = Door.CFrame * CFrame.new(0, math.rad(-4), 0)

Yes my bad. I wrote the wrong thing, let me rewrite it:

Door.CFrame = Door.CFrame * CFrame.Angles(0, math.rad(-1), 0)

It was suppose to use CFrame.Angles

Thank you so much! This fixed the issue.