Door Tweenservice issue

The left hand side of the door opens correctly. The other side decides to open the incorrect way. I have looked on the Devforum for similar issues and I haven’t found one that is related to the same issue I’m having. I have tried modifying the angles & easing direction however that didn’t change anything.

Code:

local Hinge = script.Parent.PrimaryPart
local opened = false

local TS = game:GetService("TweenService")

local teams = {game.Teams["Host Team"], game.Teams.Supervisor}

function OpenDoor()
	if opened == false then
		opened = true
		local tween = TS:Create(script.Parent.Door1.Primary, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Orientation = Vector3.new(0, 180, 90)})
		tween:Play()
		local tween2 = TS:Create(script.Parent.Door2.Primary, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Orientation = Vector3.new(0, 180, 90)})
		tween2:Play()
	else
		opened = false
		local tween = TS:Create(script.Parent.Door1.Primary, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Orientation = Vector3.new(0, 90, 90)})
		tween:Play()
		local tween2 = TS:Create(script.Parent.Door2.Primary, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Orientation = Vector3.new(0, -90, 90)})
		tween2:Play()
	end
end

script.Parent.ClickPart.ClickDetector.MouseClick:Connect(function(Player)
	if table.find(teams, Player.Team) then
		OpenDoor()
	end
end)```

You may have a sign issue. In your code, you open both doors by changing the orientation to 0, 180, 90 for both doors. In the closing algorithm, you change the orientation to 0, 90, 90 for Door 1 and 0, -90, 90 for Door 2. Notice how the y-axis for only a single door is positive when you close it, but the y-axis for both doors is positive when you open it. Try to change one of the the numbers to negative when you open the door.

It’s more than likely the orientation that need to be changed when you open the door, they’re on opposite sides so changing their orientation with the exact same value should be the problem.

Don’t change the Orientation. I’m pretty sure having 180 in there is what’s messing you up. Change the CFrame of the Anchored Parts of both doors.

I just copy/pasted this from a ProximetyPrompt set of double doors in my game. Take from it what you will:

local tweenService = game:GetService("TweenService")

prompt = script.Parent.Main
hinge1 = script.Parent.Frame.Hinge1
hinge2 = script.Parent.Frame.Hinge2

prompt = prompt.ProximityPrompt

local goalOpen1 = {}
goalOpen1.CFrame = hinge1.CFrame * CFrame.Angles(0, 0, 0)

local goalOpen2 = {}
goalOpen2.CFrame = hinge2.CFrame * CFrame.Angles(0, 0, 0)

local goalClose1 = {}
goalClose1.CFrame = hinge1.CFrame * CFrame.Angles(-math.rad(92), 0, 0)

local goalClose2 = {}
goalClose2.CFrame = hinge2.CFrame * CFrame.Angles(-math.rad(96), 0, 0)

local tweenInfoIn = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.In				
	)
local tweenInfoOut = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.Out			
	)


local tweenOpen1 = tweenService:Create(hinge1, tweenInfoOut, goalOpen1)
local tweenOpen2 = tweenService:Create(hinge2, tweenInfoOut, goalOpen2)

local tweenClose1 = tweenService:Create(hinge1, tweenInfoIn, goalClose1)
local tweenClose2 = tweenService:Create(hinge2, tweenInfoIn, goalClose2)


prompt.Triggered:Connect(function()

	if prompt.ActionText == "Close" then
		prompt.Enabled = false
		task.wait(.5)
		tweenClose1:Play()
		tweenClose2:Play()
		task.wait(2)
		prompt.ActionText = "Open"
		prompt.Enabled = true
	else
		prompt.Enabled = false
		task.wait(.5)
		tweenOpen1:Play()
		tweenOpen2:Play()
		task.wait(2)
		prompt.ActionText = "Close"
		prompt.Enabled = true
	end
	
end)

Thank you for all the feedback! I will take the orientation into consideration

1 Like

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