local DOOR_OPEN_TIME = 2
local DOOR_EASING_STYLE = Enum.EasingStyle.Quart
local DEBOUNCE_TIME = 0.25
local leftDoor = script.Parent.LeftDoor
local rightDoor = script.Parent.RightDoor
local leftOpenGoalCFrame = script.Parent.LeftGoal.CFrame
local rightOpenGoalCFrame = script.Parent.RightGoal.CFrame
local leftCloseGoalCFrame = leftDoor.CFrame
local rightCloseGoalCFrame = rightDoor.CFrame
local trigger = script.Parent.Trigger
local tweenService = game:GetService("TweenService")
local isOpen = false
local debounce = false
local function openDoors(hit)
if not isOpen and not debounce then
print("Door opening...")
isOpen = true
local leftDoorTween = tweenService:Create(leftDoor, TweenInfo.new(DOOR_OPEN_TIME, DOOR_EASING_STYLE), {CFrame = leftOpenGoalCFrame})
local rightDoorTween = tweenService:Create(rightDoor, TweenInfo.new(DOOR_OPEN_TIME, DOOR_EASING_STYLE), {CFrame = rightOpenGoalCFrame})
leftDoorTween:Play()
rightDoorTween:Play()
print("Door opened!")
end
end
local function closeDoors(hit)
if isOpen and not debounce then
print("Door closing...")
isOpen = false
local leftDoorTween = tweenService:Create(leftDoor, TweenInfo.new(DOOR_OPEN_TIME, DOOR_EASING_STYLE), {CFrame = leftCloseGoalCFrame})
local rightDoorTween = tweenService:Create(rightDoor, TweenInfo.new(DOOR_OPEN_TIME, DOOR_EASING_STYLE), {CFrame = rightCloseGoalCFrame})
leftDoorTween:Play()
rightDoorTween:Play()
print("Door closed!")
end
end
trigger.Touched:Connect(openDoors)
trigger.TouchEnded:Connect(closeDoors)