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)