local Door = script.Parent.Parent.Parent local mainPart = script.Parent.Parent.Parent.Union local Handle = script.Parent local openDoor = false Handle.ClickDetector.MouseClick:Connect(function() if openDoor == false then for i = 1, 13 do Door:SetPrimaryPartCFrame(Door:GetPrimaryPartCFrame(Vector3.new(-6.152, 3, -8.748)) * CFrame.Angles(0,math.rad(-i),0)) wait(0.01) end openDoor = true end end)
The problem I'm having is when I click the handle it rotates the door, but I also want it to move as well, so the door looks realistic and isn't just rotated in the middle of the doorway.
The easiest way to achieve this is to set the PrimaryPart of the door to a part that will act as the hinge of the door. You can do this by creating an invisible part inside of the door model that is positioned at the edge of the door, and then setting the PrimaryPart to that invisible part. As the door rotates relative to the PrimaryPart when using SetPrimaryPartCFrame, the rest of the door will rotate relative to the hinge part, creating the opening effect.
If you called the part that you wanted to rotate it relative to Hinge, you could put this on the second line of your script:
Door.PrimaryPart = Door:FindFirstChild("Hinge",true)
Otherwise, you can just set the PrimaryPart manually in the properties window.