Make a door pivot about a point using TweenService

I’m currently creating a door system where a part ‘opens’ and ‘closes’ about a point, just like a real door.

I’ve managed to achieve the majority of this using TweenService like so:

local TweenService = game:GetService("TweenService")
while wait(1) do
	local tween = TweenService:Create(script.Parent, TweenInfo.new(1,Enum.EasingStyle.Quart), {CFrame = workspace.dest.CFrame}) tween:Play() tween.Completed:wait()
	wait(1)
	local tween = TweenService:Create(script.Parent, TweenInfo.new(1,Enum.EasingStyle.Quart), {CFrame = workspace.start.CFrame}) tween:Play() tween.Completed:wait()
end

Which looks like this:
https://gyazo.com/851d22b16cc2fa9c1199ca7d5079d316

My only problem; it doesn’t pivot about a point. Instead, it sort of jumps slightly outward, then returns to the original position.

How would I fix this, ideally still using the TweenService?

3 Likes

You can display code blocks akin to how Discord does it.

3 backticks (the apostrophe looking key on the top left of your keyboard) to open and 3 to close.

Something like this is the editor:

Screenshot_20180501-150452

Will look like this when viewed:

Screenshot_20180501-150639

2 Likes

I’d recommend putting a part at the hinge, such that opening the door transforms this part in a pure rotation with no translation. Unanchor the rest of the door and weld it to the pivot, and use tweenservice on the pivot part.

4 Likes

Thanks

Okay thanks - is there anyway to achieve this without unanchoring the part?

Yeah.
Set the model’s primary part to the hinge and rotate about that point

3 Likes

Yes, but you can’t use TweenService then.

You can use tweenservice.
Use a motor6d on the door parts. It works wonders.

I used to do that until I switched to PGS Physics / constraints. What I meant is that implies un-anchroing everything but the primary part, as you cannot use SetPrimaryPartCFrame with TweenService.

1 Like

Aye - it’s an easy thing to do if you have a script setup like I do.
Constraints are good for interactives, but if you want to have a door pivot by its own accord PGS becomes messy and unreliable for consistent moment action

2 Likes

If I’m correct, he’s asking for stable doors without using Roblox physics. Try replacing the invisible parts to get the parts CFrame into having their corners touching each other instead of clipping into each other.

If that problem persist, try offsetting them away from the pivot.

Realistically, a door only has hinges on one side, causing the door to be only open into one direction instead of the other.

3 Likes

If they are welded to the centre part, which is anchored, you don’t need to worry about the other parts being unanchored

Cheers, this worked nicely. For anyone saying you can’t use TweenService on models, simply check out this post here: Tweening Models