Door swinging not working properly, need some help with the CFrames

  1. What do you want to achieve? Keep it simple and clear!

I want a normal operating door that swings and pivots on the hinge.

  1. What is the issue? Include screenshots / videos if possible!

It rotates on the wrong axis.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried moving around the CFrame values but I cannot grasp how CFrames work. I have tried.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I have this line of code in a for loop:

door:SetPrimaryPartCFrame(CFrame.new(hingepos) * CFrame.Angles(0,math.rad(i),0) * CFrame.new(4,0,0))

try making the moving Cframe negative.
Example:
door:SetPrimaryPartCFrame(CFrame.new(hingepos) * CFrame.Angles(0,math.rad(i),0) * CFrame.new(-4,0,0))

:SetPrimaryPartCFrame really isn’t an efficient way to go about things like this. :SetPrimaryPartCFrame() gradually offsets component parts
I would recommend using TweenService and tweening a hinge welded to the door. colbert2677 made a really useful post about tweening doors or other models like this.
Introduction to Tweening Models

I tried, it just turns it the other direction unfortunately.

I was afraid I’d have to do this, haha. It seems even more complex. Thank you, I will get to working on it.

1 Like

It actually wasn’t too complex fortunately. Thank you for suggesting this. I do have one issue though and I wanted to see if you could help me understand why.

So with this I was hoping that it would be a smooth transition from open to close position. Instead of that though, there is no transition at all. It’s just open, or close. Any ideas? I just copied and pasted the code from that tutorial.

1 Like

Can you send the code that you have? Make sure the model is welded and unanchored as well.

Yes. Everything is welded and anchored correctly according to the post.

local TweenService = game:GetService("TweenService")

local Panel = script.Parent
local PanelRoot = Panel.PrimaryPart

local PanelSwingInfo = TweenInfo.new() -- Let's use all defaults here

local PanelSwingTween = TweenService:Create(PanelRoot, PanelSwingInfo, {
	CFrame = PanelRoot.CFrame * CFrame.Angles(0, math.rad(180), 0)
	
})

PanelSwingTween:Play()

Okay. I’m not sure what you mean by this:

Does it just teleport from one side to the next without any animation?

Yes, exactly. If needed I can give a GIF again.

Try adding a 5 inside TweenInfo.new().

1 Like

That worked! Thank you very much :slight_smile:

1 Like