Door tween CFrame rotates into part a little instead of around it

Hi, I am trying to rotate a door around a pivot point (like a hinge) that are anchored, so I am using tweens to animate it. I have followed many tutorials and have just managed to get to this point, but I have no idea what to do now as for some reason the door rotates into the hinge for a moment when it turns around.
Demo:

Script:

local tweenservice = game:GetService("TweenService")
local door = script.Parent.Parent
local piv = door.Parent.PrimaryPart
local offset = piv.CFrame:Inverse() * door.CFrame
local info = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut, 0, false, 0)

local tween = tweenservice:Create(door, info,{CFrame = piv.CFrame * CFrame.Angles(0, math.rad(90), 0) * offset})

function left()
	tween:Play()
end

Why don’t you use a HingeConstraint? You can set the type to servo, and after you set it up you can rotate the door by just setting the target angle.

The door and the pivot point are both anchored to remove the chance physics messing with the door.

You can leave the pivot point anchored and the door unanchored, and then you can use a Servo.

Also, if you are wondering the reason is that your door is moving linearly:
image

Left is the desired result, right is reality.
Since you are moving linearly your door will move backwards since what you need is not a linear motion but instead a circular one like in the left diagram.

Black = Start
Yellow = Middle
Green = End

Purple = Center

1 Like

The reason the door is anchored is because with Constraints in ROBLOX there is always the issue that they can be very glitched via some moving physics object pushing into it at the wrong angle, I don’t want any chance of that
Though the diagrams are useful :+1:

1 Like

Glad my poorly scribbled drawings were of some help!

why not weld motors to a designated hinge part and rotate the motors that way?

1 Like

i dont want to unanchor it. roblox physics are unreliable imo and i dont want the door glitching all over the place cause of a collision issue.
is there really no way to just tween in a realistic circular motion around the hinge point?

@STORMGAMESYT7IP
@anon36900032
thanks for your help!
this post in this article explains what im looking for: Tween Part around Pivot Point

2 Likes