Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making a door swing open/close smoothly?

How would I make a door swing open or close smoothly? I'm thinking I would have to use the rotate edge formula, but I don't know that.

1 answer

✓ Accepted answer

Since this has been asked before, I'll just copy and paste my answer from another question.

Here's how you rotate a part around a point (or in your case, a door).

part.CFrame = origin*rotation*(origin:inverse()*part.CFrame)

origin is the point (CFrame, not Vector3) you're rotating around, and rotation is the CFrame you're rotating by.

You can use a simple for loop to make it open smoothly.

local origin = CFrame.new(Door.Position - Vector3.new(Door.Size.X/2,0,0))
for i = 1, 18 do
	Door.CFrame = origin * CFrame.Angles(0,math.rad(90/18),0) * (origin:inverse()*Door.CFrame)
	wait()
end

1 comment

0

That worked. Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.