Making diagonally moving doors using Tweenservice

So recently I have tried making doors move diagonally, but cannot find the solution yet. Instead, one part of the door moves upwards and the other moves the right way. There also seems to be a bug with the door (It moves to the right/left, instead of vertically). Any help with this?

Video:

Code:
local TweenService = game:GetService(“TweenService”)

local model = script.Parent

local leftDoor = model.LeftDoor

local rightDoor = model.RightDoor

local prompt = model.Top.Attachment.ProximityPrompt

local tweenInfo = TweenInfo.new(1)

local leftGoalOpen = {}

local leftGoalClose = {}

leftGoalOpen.CFrame = leftDoor.CFrame * CFrame.new(leftDoor.Size.X, 10, 0)

leftGoalClose.CFrame = leftDoor.CFrame

local leftTweenOpen = TweenService:Create(leftDoor, tweenInfo, leftGoalOpen)

local leftTweenClose = TweenService:Create(leftDoor, tweenInfo, leftGoalClose)

local rightGoalOpen = {}

local rightGoalClose = {}

rightGoalOpen.CFrame = rightDoor.CFrame * CFrame.new(rightDoor.Size.Y, 0, 0)

rightGoalClose.CFrame = rightDoor.CFrame

local rightTweenOpen = TweenService:Create(rightDoor, tweenInfo, rightGoalOpen)

local rightTweenClose = TweenService:Create(rightDoor, tweenInfo, rightGoalClose)

prompt.Triggered:Connect(function(player)

prompt.ActionText = “”

leftTweenClose:Play()

rightTweenClose:Play()

prompt.ActionText = " "

wait(2)

leftTweenOpen:Play()

rightTweenOpen:Play()

prompt.ActionText = “”

end)

I have tried looking for this on youtube along the devhub, but have not found something working for me.

I added a cooldown (aka debounce) to prevent the bug from happening that both frames of left and right side of the door drift apart.

Second is that without the model is a bit hard to do for me with 2 parts. Is there a chance you can send the two parts as a model so I can take a closer look at it?

-- Service
local TweenService = game:GetService("TweenService")

-- Cooldown
local debounce = false

-- Local destinations/parts
local model = script.Parent
local leftDoor = model.LeftDoor
local rightDoor = model.RightDoor
local prompt = model.Top.Attachment.ProximityPrompt

-- Tween information
local tweenInfo = TweenInfo.new(1)
local leftGoalOpen = {}
local leftGoalClose = {}

leftGoalOpen.CFrame = leftDoor.CFrame * CFrame.new(leftDoor.Size.X, 10, 0)
leftGoalClose.CFrame = leftDoor.CFrame

local leftTweenOpen = TweenService:Create(leftDoor, tweenInfo, leftGoalOpen)
local leftTweenClose = TweenService:Create(leftDoor, tweenInfo, leftGoalClose)
local rightGoalOpen = {}
local rightGoalClose = {}

rightGoalOpen.CFrame = rightDoor.CFrame * CFrame.new(rightDoor.Size.Y, 0, 0)
rightGoalClose.CFrame = rightDoor.CFrame

local rightTweenOpen = TweenService:Create(rightDoor, tweenInfo, rightGoalOpen)
local rightTweenClose = TweenService:Create(rightDoor, tweenInfo, rightGoalClose)


-- actual script
prompt.Triggered:Connect(function(player)
	if debounce == false then
		debounce = true
		
		prompt.ActionText = ""
		leftTweenClose:Play()
		rightTweenClose:Play()
		prompt.ActionText = " "
		
		task.wait(2)

		leftTweenOpen:Play()

		rightTweenOpen:Play()

		prompt.ActionText = ""
		
		debounce = false
	end


end)

Hey!
Thanks for the reply!

Here is the model in which i exported.
https://www.roblox.com/library/9027245079/Door-Forum

If there is anything missing please tell me.

Thanks!

Ah thank you, before i continue i’m a bit confused how your door works. So i got a suggestion if you want that in your door or not.

Do you want:
Door open > door close
Or:
if statement to check if open/close
open > close
Close > open
Or your old way:
Door opens
stays open
Button make the door close for 2 second then open again

The script with fixed positions:

-- Service
local TweenService = game:GetService("TweenService")

-- Cooldown
local debounce = false

-- Local destinations/parts
local model = script.Parent
local leftDoor = model.LeftDoor
local rightDoor = model.RightDoor
local prompt = model.Top.Attachment.ProximityPrompt

-- Tween information
local tweenInfo = TweenInfo.new(1)
local leftGoalOpen = {}
local leftGoalClose = {}

leftGoalOpen.CFrame = leftDoor.CFrame * CFrame.new(0, 10, 5)
leftGoalClose.CFrame = leftDoor.CFrame

local leftTweenOpen = TweenService:Create(leftDoor, tweenInfo, leftGoalOpen)
local leftTweenClose = TweenService:Create(leftDoor, tweenInfo, leftGoalClose)
local rightGoalOpen = {}
local rightGoalClose = {}

rightGoalOpen.CFrame = rightDoor.CFrame * CFrame.new(0,10, -10)
rightGoalClose.CFrame = rightDoor.CFrame

local rightTweenOpen = TweenService:Create(rightDoor, tweenInfo, rightGoalOpen)
local rightTweenClose = TweenService:Create(rightDoor, tweenInfo, rightGoalClose)


-- actual script
prompt.Triggered:Connect(function(player)
	if debounce == false then
		debounce = true

		prompt.ActionText = ""
		leftTweenClose:Play()
		rightTweenClose:Play()
		prompt.ActionText = " "

		task.wait(2)

		leftTweenOpen:Play()

		rightTweenOpen:Play()

		prompt.ActionText = ""

		debounce = false
	end


end)

The first one, “door open to door close”. I really do not know how to make it close by itself and struff like that.

Thanks so much for your help!

Alright, done that for you.

Basically you had it first on the closing tween before opening the door. Turning that around will allow you to open the door first and THEN close the door.

Here is the model for you, i hope this helped you out and if there is any issues feel free to look me up! :slight_smile:
https://www.roblox.com/library/9027924217/DoorForYousif455

1 Like

Thank you so much!

I’ll mark it as a solution :wink:

1 Like