Door Won't Close

Hey all!

I made a script where you can click to open and close a set of doors. One of the doors opens and closes, but the other only opens. Any reason for this?

Script for both doors:

local frame = script.Parent
local clickDetector = frame:WaitForChild("ClickDetector")
local model = frame.Parent
local Close = model:WaitForChild("DoorClose")
local Open = model:WaitForChild("DoorOpen")
local opened = model:WaitForChild("Opened")
local tweenService = game:GetService("TweenService")

local debounce = true
clickDetector.MouseClick:Connect(function()
	if debounce == true then
		debounce = false
		if opened.Value == true then
			opened.Value = false

			tweenService:Create(frame,TweenInfo.new(0.65),{CFrame = Close.CFrame}):Play()
		else
			opened.Value = true

			tweenService:Create(frame,TweenInfo.new(0.65),{CFrame = Open.CFrame}):Play()
		end

		wait(0.65)
		debounce = true
	end
end)
3 Likes

Do they share the same opened Value?

2 Likes

So you have left and right doors in a frame and you want both to slide open when clicked, then slide closed when clicked again?
Don’t you need 2 tweens to open both doors to their final positions, then 2 tweens to close them?

On another note, wait(0.65) has been deprecated. You should use task.wait(0.65) instead.

1 Like

I’m pretty sure that the {CFrame} property doesn’t work on tweens. Try positions instead, because I’ve tried the cframe before and I’ve had many issues with it.

tweenservice:Create(frame, TweenInfo.new(0.65), {Position = Close.Position}):Play() -- close

tweenservice:Create(frame, TweenInfo.new(0.65), {Position = Open.Position}):Play() -- open