Door not opening?

When the DoorHandle is clicked, the door should open and make a sound. After 5 seconds, the door should close and make a sound.

When I try to open the door, nothing happens, only the sound is played.

I have tried interchanging the PhantomDoorFrame names.

There are also two DoorHandles, each on both sides of the door. Their children are the same and scripts too.

local tweenService = game:GetService("TweenService")
local doorFrame = script.Parent.Parent.DoorFrame
local phantomDoorFrame1 = script.Parent.Parent.PhantomDoorFrame1
local phantomDoorFrame2 = script.Parent.Parent.PhantomDoorFrame2
local doorOpenSound = script.Parent.Parent.DoorFrame.DoorOpen
local doorCloseSound = script.Parent.Parent.DoorFrame.DoorClose
local clickDetector = script.Parent.ClickDetector

local tweeningInformation1 = TweenInfo.new(
	0.25, -- Duration
	Enum.EasingStyle.Back, -- Easing style
	Enum.EasingDirection.Out, -- Easing Direction
	0, -- Number of repetitions
	false, -- Reverse boolean
	0 -- Delay time between each repetition
)

local partProperties1 = {
	Position = phantomDoorFrame2.Position;
	Orientation = phantomDoorFrame2.Orientation
}

local partProperties2 = {
	Position = phantomDoorFrame1.Position;
	Orientation = phantomDoorFrame1.Orientation
}

local tween1 = tweenService:Create(doorFrame, tweeningInformation1, partProperties1)
local tween2 = tweenService:Create(doorFrame, tweeningInformation1, partProperties2)

function openDoor()
	local debounce = false
	if debounce == false then
		doorOpenSound:Play()
		tween1:Play()
		debounce = true
		wait(5)
		debounce = false
		if debounce == false then
			doorCloseSound:Play()
			tween2:Play()
		end
	end
end

clickDetector.MouseClick:Connect(openDoor)
1 Like

I can’t put my finger on the problem but I do have some ideas for trouble shooting it. You should try and put “print(“Check 1”)” at certain parts of the function to test if it’s running. Also, you should tween the doors “CFrame” property alone. It’s a combination of position and orientation in only 1 line of code. Another thing to note. You may want to define your property variables and info and tween variables in the function since in the past I’ve had issues tweening objects when the tweening properties and information was outside of the function.

It’s this part that’s not working

if debounce == false then
			doorCloseSound:Play()
			tween2:Play()
		end
1 Like

Nvermid, I’ll just use another method.

1 Like