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?
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