TweenService moving part rotation issue

Hello! I’m currently working on an event venue and the entrance is supposed to have these flush doors that pop out to expose the main house/audience area. The script I’m using rotates the part back to 0,0,0, when the script has no line that includes rotation. Is anyone able to help?

GIF of what is not supposed to happen and the problem I am having:
https://gyazo.com/fd41ed3e98acd28d386c49ed111f5256

Script:


function tweenModel(model, timee, CF)
	enabled = false
	local CFrameValue = Instance.new("CFrameValue")
	CFrameValue.Value = model:GetPrimaryPartCFrame()
	CFrameValue:GetPropertyChangedSignal("Value"):Connect(function()
		model:SetPrimaryPartCFrame(CFrameValue.Value)
	end)
	local tween = TweenService:Create(CFrameValue, TweenInfo.new(timee, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Value = CF})
	tween:Play()
	tween.Completed:Connect(function()
		CFrameValue:Destroy()
		enabled = true
	end)
end

local Ttoggle = false
local Tenabled = true
script.Parent.T.SurfaceGui.TextButton.MouseButton1Click:Connect(function()
	if Ttoggle == false and Tenabled == true then
		Tenabled = false
		Ttoggle = true
		tweenModel(script.Parent.OrchestraDoorLeft.DoorLeft, 5, CFrame.new(script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.X, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.OrchestraDoorLeft.DoorRight, 5, CFrame.new(script.Parent.OrchestraDoorLeft.DoorRight.Main.Position.X - 1, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorLeft.DoorRight.Main.Position.Z + 5))
		tweenModel(script.Parent.OrchestraDoorRight.DoorLeft, 5, CFrame.new(script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.X, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.OrchestraDoorRight.DoorRight, 5, CFrame.new(script.Parent.OrchestraDoorRight.DoorRight.Main.Position.X - 1, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorRight.DoorRight.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine1Left.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine1Left.DoorLeft.Main.Position.X, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine1Left.DoorRight, 5, CFrame.new(script.Parent.Mezzanine1Left.DoorRight.Main.Position.X - 1, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Left.DoorRight.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine1Right.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine1Right.DoorLeft.Main.Position.X, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine1Right.DoorRight, 5, CFrame.new(script.Parent.Mezzanine1Right.DoorRight.Main.Position.X - 1, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Right.DoorRight.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine2Left.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine2Left.DoorLeft.Main.Position.X, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine2Left.DoorRight, 5, CFrame.new(script.Parent.Mezzanine2Left.DoorRight.Main.Position.X - 1, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Left.DoorRight.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine2Right.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine2Right.DoorLeft.Main.Position.X, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine2Right.DoorRight, 5, CFrame.new(script.Parent.Mezzanine2Right.DoorRight.Main.Position.X - 1, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Right.DoorRight.Main.Position.Z + 5))
		wait(5)
		Tenabled = true
	elseif Ttoggle == true and Tenabled == true then
		Tenabled = false
		Ttoggle = false
		tweenModel(script.Parent.OrchestraDoorLeft.DoorLeft, 5, CFrame.new(script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.X, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.OrchestraDoorLeft.DoorRight, 5, CFrame.new(script.Parent.OrchestraDoorLeft.DoorRight.Main.Position.X + 1, script.Parent.OrchestraDoorLeft.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorLeft.DoorRight.Main.Position.Z - 5))
		tweenModel(script.Parent.OrchestraDoorRight.DoorLeft, 5, CFrame.new(script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.X, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.OrchestraDoorRight.DoorRight, 5, CFrame.new(script.Parent.OrchestraDoorRight.DoorRight.Main.Position.X + 1, script.Parent.OrchestraDoorRight.DoorLeft.Main.Position.Y, script.Parent.OrchestraDoorRight.DoorRight.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine1Left.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine1Left.DoorLeft.Main.Position.X, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine1Left.DoorRight, 5, CFrame.new(script.Parent.Mezzanine1Left.DoorRight.Main.Position.X + 1, script.Parent.Mezzanine1Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Left.DoorRight.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine1Right.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine1Right.DoorLeft.Main.Position.X, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine1Right.DoorRight, 5, CFrame.new(script.Parent.Mezzanine1Right.DoorRight.Main.Position.X + 1, script.Parent.Mezzanine1Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine1Right.DoorRight.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine2Left.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine2Left.DoorLeft.Main.Position.X, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine2Left.DoorRight, 5, CFrame.new(script.Parent.Mezzanine2Left.DoorRight.Main.Position.X + 1, script.Parent.Mezzanine2Left.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Left.DoorRight.Main.Position.Z - 5))
		tweenModel(script.Parent.Mezzanine2Right.DoorLeft, 5, CFrame.new(script.Parent.Mezzanine2Right.DoorLeft.Main.Position.X, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Z + 5))
		tweenModel(script.Parent.Mezzanine2Right.DoorRight, 5, CFrame.new(script.Parent.Mezzanine2Right.DoorRight.Main.Position.X + 1, script.Parent.Mezzanine2Right.DoorLeft.Main.Position.Y, script.Parent.Mezzanine2Right.DoorRight.Main.Position.Z - 5))
		wait(5)
		Tenabled = true
	end
end)
2 Likes

Please format your code correctly and give us a line #. Thanks!

Use ``` to format code

Please attempt to search for a solution to your problem before posting here. The Developer Hub article on CFrames is a good source to reference to better understand what your script is doing.

Quote directly from the first line of the article:

A CFrame, short for Coordinate Frame, is a data type used to rotate and position 3D objects.

If you’re making a new CFrame then you should make sure the rotation of the door is set in that CFrame, since the default is 0,0,0

1 Like

My apologies. Was not sure how to do it when I posted.

Alright. Thank you for the help.

I think you should ditch that method of SetPrimaryPartCFrame. This probably could also help you with your problem, provided you understand the root cause.

All you’d have to do is move a door forward or back in respect to the look vector.

2 Likes