When the tween in my Open Door Script finishes, it should tick the OpenValue’s boolean, and when the boolean is ticked, the Close Door Script triggers and it unticks the OpenValue boolean when it’s finished.
But, when the Open Door Script is finished, the OpenValue’s boolean doesn’t tick, and therefore, the Close Door Script closes.
I have tried removing the “Value” at the end of the OpenValue’s boolean value.
No errors relating to the script can be found.
Open Door Script
local tweenService = game:GetService("TweenService")
local doorFrame = script.Parent.Parent.DoorFrame
local phantomDoorFrame1 = script.Parent.Parent.PhantomDoorFrame1
local clickDetector = script.Parent.ClickDetector
local openValue = script.Parent.Parent.DoorFrame.OpenValue.Value
local tweeningInformation = 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 partProperties = {
Position = phantomDoorFrame1.Position;
Orientation = phantomDoorFrame1.Orientation
}
local tween = tweenService:Create(doorFrame, tweeningInformation, partProperties)
function openDoor()
if openValue == false then
tween:Play()
openValue = true
end
end
clickDetector.MouseClick:Connect(openDoor)
Close Door Script
local tweenService = game:GetService("TweenService")
local doorFrame = script.Parent.Parent.DoorFrame
local phantomDoorFrame2 = script.Parent.Parent.PhantomDoorFrame2
local openValue = script.Parent.Parent.DoorFrame.OpenValue.Value
local tweeningInformation = 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 partProperties = {
Position = phantomDoorFrame2.Position;
Orientation = phantomDoorFrame2.Orientation
}
local tween = tweenService:Create(doorFrame, tweeningInformation, partProperties)
function closeDoor()
if openValue == true then
wait(5)
tween:Play()
openValue = false
end
end
closeDoor()