I'm making a door that rotates around a hinge (Not an actual HingeConstraint). The first thing that came to my mind was to use TweenService to rotate it on the hinge, however I just cant seem to get it working. I thought about using CFrames but I don't quite understand how they work. Any suggestions?
Rotating a part around a point using TweenService?
1 answer
There's this thing called CFrame:ToWorldSpace(), function transforms an object’s Coordinate-Frame — respecting its own local orientation — to a new world orientation. This makes it ideal for offsetting a part relative to itself or another object, regardless of how it’s currently positioned/rotated.
In the code below, notice that the Door gets offset 2 studs relative to the Y axis of the hinge (the up and down axis) and not relative to the global Y axis pointing straight up.
local Door = game.Workspace.Doorframe
local DoorHinge = game.Workspace.Hinge
local offsetCFrame = CFrame.new(0, 2, 0)
Door.CFrame = DoorHinge.CFrame:ToWorldSpace(offsetCFrame)
If you test this now, it looks like the part, Doorframe is connected to the part, Hinge. Add a loop onto the script above, then make the hinge spin. If you dont know how to use CFrames, read this article on roblox. -- https://developer.roblox.com/en-us/articles/Understanding-CFrame
1 comment
hi
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
why dont you just change the rotation value on the part?
Roblox, by default, rotates parts around their center point.
set the primarypart of the model to the hinge and rotate that (assuming the door and hinge is grouped apart from the entire door)