READ UNTIL END
Here is my code:
local touchPart = script.Parent.touchPart
local a = script.Parent.DoorA
local b = script.Parent.DoorB
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1.584,Enum.EasingStyle.Circular)
local aOpen = tweenService:Create(a,tweenInfo,{CFrame = a.CFrame + a.CFrame.ZVector * 4.4})
local aClosed = tweenService:Create(a,tweenInfo,{CFrame = a.CFrame})
local bOpen = tweenService:Create(b,tweenInfo,{CFrame = b.CFrame + b.CFrame.ZVector * -4.4})
local bClosed = tweenService:Create(b,tweenInfo,{CFrame = b.CFrame})
local inaction = false
local function Open()
if inaction == false then
inaction = true
script.Parent.lightA.BrickColor = BrickColor.new("Lime green")
aOpen:Play()
bOpen:Play()
script.Parent.Sound:Play()
aOpen.Completed:Wait()
bOpen.Completed:Wait()
inaction = false
end
end
local function Close()
if inaction == false then
inaction = true
script.Parent.lightA.BrickColor = BrickColor.new("Really red")
aClosed:Play()
bClosed:Play()
script.Parent.Sound:Play()
aClosed.Completed:Wait()
bClosed.Completed:Wait()
inaction = false
end
end
touchPart.Touched:Connect(function()
print("open")
Open()
end)
touchPart.TouchEnded:Connect(function()
print("close")
Close()
end)
and here are the items in the explorer:
And when I touch the part, the door does open but when I stop touching the part and reach the other side of the door the door doesn’t close, even though it DOES print out “close”.
I am completely and utterly baffled so any help would be greatly appreciated.
Thanks.