Door Hinges and Handle Interrupting Each Other

I want to script a door, in which it opens and the knob turns slightly and reverses back, and I used TweenService for that.

The good thing is that both tweens work correctly; the problem is that when both tweens end up playing together, the door only opens and the knob does not play its animation.

I tried looking at this article: Hyperlink, but the given example is very different from my layout in the explorer.

Firstly, the door actually has 3 hinges all welded to the door, and are scripted to tween at the same time.

Secondly, the door has 2 handles - one for the backside, and one for the front. These handles are welded to an invisible part in the ideal position and the part itself is welded to the door.

This is my layout in the Explorer:
image

  • Handle.000 & Handle.001 are welded to HandleInvis which is welded to Door.
  • The Hinges model contains 3 hinges which are welded to Door.
  • Everything else is welded to Door.
1 Like

May you provide a video example of it’s current behaviour and your tweening code? We can’t do much with the things you provided.

Here is some footage:

The door behaves differently when I anchor or unanchor the handle.

local TweenService = game:GetService("TweenService")

local door = script.Parent.Door
local hinges = script.Parent.Hinges
local prompt = door.ProximityPrompt
local knob = {
	script.Parent.Handle.HandleInvis;
	script.Parent.Handle["Handle.000"];
	script.Parent.Handle["Handle.001"];
}

local goalOpen = {
	{CFrame = hinges.Hinge1.CFrame * CFrame.Angles(0, math.rad(90), 0)};
	{CFrame = hinges.Hinge2.CFrame * CFrame.Angles(0, math.rad(90), 0)};
	{CFrame = hinges.Hinge3.CFrame * CFrame.Angles(0, math.rad(90), 0)};
	{CFrame = knob[1].CFrame * CFrame.Angles(0, 0, math.rad(30))};
}

local goalClose = {
	{CFrame = hinges.Hinge1.CFrame * CFrame.Angles(0, math.rad(0), 0)};
	{CFrame = hinges.Hinge2.CFrame * CFrame.Angles(0, math.rad(0), 0)};
	{CFrame = hinges.Hinge3.CFrame * CFrame.Angles(0, math.rad(0), 0)};
	{CFrame = knob[1].CFrame * CFrame.Angles(0, 0, math.rad(0))};
}

local tweenInfo = {
	TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.Out,
		0,
		false,
		0
	);
	TweenInfo.new(
		0.3,
		Enum.EasingStyle.Cubic,
		Enum.EasingDirection.InOut,
		0,
		true,
		0
	);
}

local tweenOpen = {
	TweenService:Create(hinges.Hinge1, tweenInfo[1], goalOpen[1]);
	TweenService:Create(hinges.Hinge2, tweenInfo[1], goalOpen[2]);
	TweenService:Create(hinges.Hinge3, tweenInfo[1], goalOpen[3]);
	TweenService:Create(knob[1], tweenInfo[2], goalOpen[4]);
	TweenService:Create(knob[2], tweenInfo[2], goalOpen[4]);
}

local tweenClose = {
	TweenService:Create(hinges.Hinge1, tweenInfo[1], goalClose[1]);
	TweenService:Create(hinges.Hinge2, tweenInfo[1], goalClose[2]);
	TweenService:Create(hinges.Hinge3, tweenInfo[1], goalClose[3]);
}

local Sound = Instance.new("Sound")
Sound.SoundId = "rbxassetid://15524073135"
Sound.EmitterSize = 5
Sound.Parent = door

prompt.Triggered:Connect(function()
	if prompt.ActionText == "Close" then
		tweenClose[1]:Play()
		tweenClose[2]:Play()
		tweenClose[3]:Play()

		tweenOpen[4]:Play()
		tweenOpen[5]:Play()

		prompt.Enabled = false
		prompt.ActionText = "Open"
		Sound:Play()
		tweenClose[3].Completed:Wait()
		prompt.Enabled = true
	elseif prompt.ActionText == "Open" then
		tweenOpen[1]:Play()
		tweenOpen[2]:Play()
		tweenOpen[3]:Play()

		tweenOpen[4]:Play()
		tweenOpen[5]:Play()

		prompt.Enabled = false
		prompt.ActionText = "Close"
		Sound:Play()
		tweenOpen[3].Completed:Wait()
		prompt.Enabled = true
	else
		error()
	end
end)

Not too sure yet, I will build a door with hinge to test later, don’t have access to studio currently. Try disabling door tweens and check if hinge tweens work? I will follow up later.

Yup, I have already tried tweening them seperately.

The door tweens correctly, the handle tweens correctly.

I have also tried tweening them at the same time and disabled the weld between the handles and the door; it also works. It’s just that welding the handle to the door doesn’t work since probably the door is already tweening before the handle can actually tween.

What is Hinge1, Hinge2 and Hinge3?
I would think you only need 1 hinge to control the open/close of the door and one for the knob. Why there are 3 hinges for 1 door?

I think you can check out this topic:
https://devforum.roblox.com/t/tweening-locally-with-welded-parts/2481525

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.