Paste
Pasted as Lua by perpanther ( 6 years ago )
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local Lift = script.Parent
local debounce = false
local Door11 = game.Workspace.Door11
local Door12 = game.Workspace.Door12
local Door21 = game.Workspace.Door21
local Door22 = game.Workspace.Door22
local Door31 = game.Workspace.Door31
local Door32 = game.Workspace.Door32
local LiftGroup = game.Workspace.LiftGroup
local InDoor1 = LiftGroup.InDoor1
local InDoor2 = LiftGroup.InDoor2
local InDoors = {InDoor1, InDoor2}
local CD1 = game.Workspace.Part1.ClickDetector
local CD2 = game.Workspace.Part2.ClickDetector
local CD3 = game.Workspace.Part3.ClickDetector
local LiftPos = Lift.Position
local newThread = coroutine.create(function()
while wait() do
LiftPos = Lift.Position
end
end)
coroutine.resume(newThread)
for _, Part0 in pairs (LiftGroup:GetChildren()) do
if Part0:IsA("BasePart") and not (Part0 == Lift) then
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = Part0
WeldConstraint.Part1 = Lift
WeldConstraint.Parent = WeldConstraint.Part0
end
end
local Tweenfo = TweenInfo.new(
3,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local Goals1 =
{
CFrame = CFrame.new(0,0,0)
}
local Goals2 =
{
CFrame = CFrame.new(0,15,0)
}
local Goals3 =
{
CFrame = CFrame.new(0,30,0)
}
local TweenLift1 = TweenService:Create(Lift, Tweenfo, Goals1)
local TweenLift2 = TweenService:Create(Lift, Tweenfo, Goals2)
local TweenLift3 = TweenService:Create(Lift, Tweenfo, Goals3)
local DoorOpenTweenfo = TweenInfo.new(
2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.In,
0,
false,
0
)
local DoorGoals11 = {Position = Vector3.new(7.85,5.75,-5.35)}
local DoorGoals12 = {Position = Vector3.new(-7.85,5.75,-5.35)}
local DoorGoals21 = {Position = Vector3.new(7.85,20.75,-5.35)}
local DoorGoals22 = {Position = Vector3.new(-7.85,20.75,-5.35)}
local DoorGoals31 = {Position = Vector3.new(7.85,35.75,-5.35)}
local DoorGoals32 = {Position = Vector3.new(-7.85,35.75,-5.35)}
local DoorCloseGoals11 = {Position = Vector3.new(2.96,5.75,-5.35)}
local DoorCloseGoals12 = {Position = Vector3.new(-2.96,5.75,-5.35)}
local DoorCloseGoals21 = {Position = Vector3.new(2.96,20.75,-5.35)}
local DoorCloseGoals22 = {Position = Vector3.new(-2.96,20.75,-5.35)}
local DoorCloseGoals31 = {Position = Vector3.new(2.96,35.75,-5.35)}
local DoorCloseGoals32 = {Position = Vector3.new(-2.96,35.75,-5.35)}
local InDoorGoals1 = {Position = Vector3.new(LiftPos.X-InDoor1.Size.X-2.711, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorGoals2 = {Position = Vector3.new(LiftPos.X+InDoor1.Size.X+2.711, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorCloseGoals1 = {Position = Vector3.new(LiftPos.X-2.71, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local InDoorCloseGoals2 = {Position = Vector3.new(LiftPos.X+2.71, LiftPos.Y+5.8, LiftPos.Z-5.5)}
local TweenDoor1 = TweenService:Create(Door11, DoorOpenTweenfo, DoorGoals11)
local TweenDoor12 = TweenService:Create(Door12, DoorOpenTweenfo, DoorGoals12)
local TweenDoor2 = TweenService:Create(Door21, DoorOpenTweenfo, DoorGoals21)
local TweenDoor22 = TweenService:Create(Door22, DoorOpenTweenfo, DoorGoals22)
local TweenDoor3 = TweenService:Create(Door31, DoorOpenTweenfo, DoorGoals31)
local TweenDoor32 = TweenService:Create(Door32, DoorOpenTweenfo, DoorGoals32)
local TweenCloseDoor1 = TweenService:Create(Door11, DoorOpenTweenfo, DoorCloseGoals11)
local TweenCloseDoor12 = TweenService:Create(Door12, DoorOpenTweenfo, DoorCloseGoals12)
local TweenCloseDoor2 = TweenService:Create(Door21, DoorOpenTweenfo, DoorCloseGoals21)
local TweenCloseDoor22 = TweenService:Create(Door22, DoorOpenTweenfo, DoorCloseGoals22)
local TweenCloseDoor3 = TweenService:Create(Door31, DoorOpenTweenfo, DoorCloseGoals31)
local TweenCloseDoor32 = TweenService:Create(Door32, DoorOpenTweenfo, DoorCloseGoals32)
local TweenCloseDoor = {{TweenCloseDoor1, TweenCloseDoor12},{TweenCloseDoor2, TweenCloseDoor22},{TweenCloseDoor3, TweenCloseDoor32}}
local TweenDoor = {{TweenDoor1, TweenDoor12},{TweenDoor2, TweenDoor22},{TweenDoor3, TweenDoor32}}
local TweenCloseIndoor1 = TweenService:Create(InDoor1, DoorOpenTweenfo, InDoorCloseGoals1)
local TweenCloseIndoor2 = TweenService:Create(InDoor2, DoorOpenTweenfo, InDoorCloseGoals2)
local TweenIndoor1 = TweenService:Create(InDoor1, DoorOpenTweenfo, InDoorGoals1)
local TweenIndoor2 = TweenService:Create(InDoor2, DoorOpenTweenfo, InDoorGoals2)
local function OpenInDoors(InDoor)
TweenIndoor1:Play()
TweenIndoor2:Play()
end
local function CloseInDoors(InDoor)
TweenCloseIndoor1:Play()
TweenCloseIndoor2:Play()
end
local function CloseDoors(Door)
for _,Door in pairs(TweenCloseDoor) do
Door[1]:Play()
Door[2]:Play()
end
end
local function OpenDoor(Door)
Door[1]:Play()
Door[2]:Play()
end
function OpenDoors()
for _,Door in pairs(TweenDoor) do
OpenDoor(Door)
end
end
CD1.MouseClick:Connect(function()
if debounce then return
else
debounce = true
CloseDoors()
TweenCloseDoor1.Completed:wait()
CloseInDoors()
for _, InDoor in pairs (InDoors) do
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = InDoor
WeldConstraint.Part1 = Lift
WeldConstraint.Parent = WeldConstraint.Part0
InDoor.Anchored = false
end
wait(2)
TweenLift1:Play()
TweenLift1.Completed:Connect(function()
for _,InDoor in pairs (InDoors) do
InDoor:WaitForChild("WeldConstraint"):Destroy()
InDoor.Anchored = true
end
OpenInDoors()
TweenIndoor1.Completed:wait()
OpenDoor(TweenDoor[1])
end)
TweenDoor1.Completed:wait()
debounce = false
end
end)
CD2.MouseClick:Connect(function()
if debounce then return
else
debounce = true
CloseDoors()
TweenCloseDoor2.Completed:wait()
CloseInDoors()
for _, InDoor in pairs (InDoors) do
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = InDoor
WeldConstraint.Part1 = Lift
WeldConstraint.Parent = WeldConstraint.Part0
InDoor.Anchored = false
end
wait(2)
TweenLift2:Play()
TweenLift2.Completed:Connect(function()
for _,InDoor in pairs (InDoors) do
InDoor:WaitForChild("WeldConstraint"):Destroy()
InDoor.Anchored = true
end
OpenInDoors()
TweenIndoor1.Completed:wait()
OpenDoor(TweenDoor[2])
end)
TweenDoor2.Completed:wait()
debounce = false
end
end)
CD3.MouseClick:Connect(function()
if debounce then return
else
debounce = true
CloseDoors()
TweenCloseDoor3.Completed:wait()
CloseInDoors()
for _, InDoor in pairs (InDoors) do
local WeldConstraint = Instance.new("WeldConstraint")
WeldConstraint.Part0 = InDoor
WeldConstraint.Part1 = Lift
WeldConstraint.Parent = WeldConstraint.Part0
InDoor.Anchored = false
end
wait(2)
TweenLift3:Play()
TweenLift3.Completed:Connect(function()
for _,InDoor in pairs (InDoors) do
InDoor:WaitForChild("WeldConstraint"):Destroy()
InDoor.Anchored = true
end
OpenInDoors()
TweenIndoor1.Completed:wait()
OpenDoor(TweenDoor[3])
end)
TweenDoor3.Completed:wait()
debounce = false
end
end)
Revise this Paste