Double Door takes two attempts to open the first time

Hi, i adapted a door script i had to double doors and it works for the most part however, the first time you use the doors, you have to use the prompt twice

local TweenService = game:GetService("TweenService")

local door = script.Parent.Part
local hinge1 = script.Parent["Metal Door"].sart
local hinge2 = script.Parent["Metal Door2"].sart
local prompt = door.ProximityPrompt

local goalOpen = {}

goalOpen.CFrame = hinge1.CFrame * CFrame.Angles(0, math.rad(-90), 0)

local goalOpen1 = {}

goalOpen1.CFrame = hinge2.CFrame * CFrame.Angles(0, math.rad(90), 0)
local goalClose = {}
goalClose.CFrame = hinge1.CFrame * CFrame.Angles(0, 0, 0)

local goalClose1 = {}

goalClose1.CFrame = hinge2.CFrame * CFrame.Angles(0, 0, 0)
local tweenInfo = TweenInfo.new(1)
local tweenOpen = TweenService:Create(hinge1, tweenInfo, goalOpen)
local tweenOpen1 = TweenService:Create(hinge2, tweenInfo, goalOpen1)
local tweenClose = TweenService:Create(hinge1, tweenInfo, goalClose)
local tweenClose1 = TweenService:Create(hinge2, tweenInfo, goalClose1)
local open = 0

prompt.Triggered:Connect(function()
	if open == 0 then
		open = 1
		tweenClose:Play()
		tweenClose1:Play()
		door["Door Opening"]:Play()

	else
		door["Door Opening"]:Play()

		open = 0
		tweenOpen:Play()
		tweenOpen1:Play()

	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

It’s because when you run the game, the doors are closed, but the Open value is saying its open, because it’s set to 0.

Change

local open = 0

to

local open = 1
2 Likes

ty, i dont know how i didnt notice that lol

1 Like

Please mark @metatablesnow’s post as the Solution so others don’t keep trying to solve it.
It’ll also help others if they have the same problem.

2 Likes