Prevent Part from going down when Tweening

It’s my first time using TweenService for parts, when it tweens to the grey part (as seen below) the red part goes down in height, until essentially the grey part is in the middle of it.

This is my script:

local TweenService = game:GetService("TweenService")

local part = script.Parent.Parent
local B = game.Workspace.Partb
local C = game.Workspace.Partc


local TweenInformation = TweenInfo.new(

5, --length
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
false
)

local partPropertiesOpened = {
	CFrame = B.CFrame 

}

local partPropertiesClosed = {
	CFrame = C.CFrame 

}

local enabled = false
function TweenDoor()
	if enabled == false then
		enabled = true
		local Tween = TweenService:Create(part,TweenInformation,partPropertiesOpened)
	Tween:Play()

elseif enabled == true then
		enabled = false
		local CTween = TweenService:Create(part,TweenInformation,partPropertiesClosed)
		CTween:Play()
	end
	
end

part.ClickDetector.MouseClick:Connect(TweenDoor)

Once again, i’m not familiar with Tweening parts so any help is apperciated!

The only cause of this could be, that PartC is lower than PartB. Check its Y-axis position, it must be same!

EDIT: Other problem I see, is that you start with the Part above the PartB and it finishes in the middle of PartC, put the Part into the Center of PartB

Thank you! I was attempting to rotate it only without it moving up or down and wasn’t aware about how Y-Axis would affect it.

1 Like