Advertisement
Guest User

mvkhvjkvvvyvyutikdfc

a guest
Mar 29th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. -- // Services
  2. local TweenService = game:GetService("TweenService")
  3.  
  4. -- // Variables
  5. local State = script.Parent:WaitForChild("State")
  6. local Busy = script.Parent:WaitForChild("Busy")
  7. local Door = script.Parent:WaitForChild("Door")
  8. local Ladder = script.Parent:WaitForChild("Ladder")
  9.  
  10. local DoorObjects = {
  11. Knobs = Door:WaitForChild("Knobs"),
  12. LockModel = Door:WaitForChild("LockModel"),
  13. Rope = Door:WaitForChild("Rope"),
  14.  
  15. Ladder1 = Ladder,
  16. Ladder2 = Ladder:WaitForChild("Second"),
  17. Ladder3 = Ladder.Second:WaitForChild("Third")
  18. }
  19.  
  20. local OriginalCFrames = {
  21. Knobs = DoorObjects.Knobs.PrimaryPart.CFrame,
  22. LockModel = DoorObjects.LockModel.PrimaryPart.CFrame,
  23. Rope = DoorObjects.Rope.PrimaryPart.CFrame,
  24.  
  25. Ladder1 = DoorObjects.Ladder1.PrimaryPart.CFrame,
  26. Ladder2 = DoorObjects.Ladder2.PrimaryPart.CFrame,
  27. Ladder3 = DoorObjects.Ladder3.PrimaryPart.CFrame
  28. }
  29.  
  30. function TweenModel(Obj, Info, Pos, Wait)
  31. local OldCFrame = Obj:FindFirstChild(Obj.Name)
  32. if OldCFrame and OldCFrame:IsA("CFrameValue") then OldCFrame:Destroy() end
  33. local CFrameValue = Instance.new("CFrameValue")
  34. CFrameValue.Name = Obj.Name
  35. CFrameValue.Parent = Obj
  36. CFrameValue.Value = Obj:GetPrimaryPartCFrame()
  37. CFrameValue:GetPropertyChangedSignal("Value"):Connect(function() Obj:SetPrimaryPartCFrame(CFrameValue.Value) end)
  38. local TweenInf = TweenInfo.new(Info.Time,Info.Style,Info.Direction,Info.Repeat or 0,Info.Reverse or false)
  39. local Tween = TweenService:Create(CFrameValue, TweenInf, {Value = Pos})
  40. Tween:Play()
  41. Tween.Completed:Connect(function()
  42. if Wait then
  43. Wait()
  44. end
  45. if CFrameValue ~= nil then
  46. CFrameValue:Destroy()
  47. end
  48. end)
  49. end
  50.  
  51. function OpenAtticDoor()
  52. local Info = {Time = 0.6, Style = Enum.EasingStyle.Back, Direction = Enum.EasingDirection.Out}
  53. local Pos = OriginalCFrames.Knobs * CFrame.Angles(math.rad(45), 0, 0)
  54. TweenModel(DoorObjects.Knobs, Info, Pos)
  55. local Info = {Time = 0.6, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  56. local Pos = OriginalCFrames.Rope * CFrame.new(0, 0, -5)
  57. TweenModel(DoorObjects.Rope, Info, Pos)
  58. wait(0.6)
  59. local Info = {Time = 0.7, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  60. local Pos = Door.PrimaryPart.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
  61. TweenModel(Door, Info, Pos)
  62. wait(.5)
  63. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  64. local Pos = script.Parent.Ladder.Ladder1.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
  65. TweenModel(DoorObjects.Ladder1, Info, Pos)
  66. wait(.5)
  67. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  68. local Pos = script.Parent.Ladder.Second.Ladder2.CFrame * CFrame.Angles(math.rad(190), 0, 0)
  69. TweenModel(DoorObjects.Ladder2, Info, Pos)
  70. wait(.5)
  71. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  72. local Pos = script.Parent.Ladder.Second.Third.Ladder3.CFrame * CFrame.Angles(math.rad(-190), 0, 0)
  73. TweenModel(DoorObjects.Ladder3, Info, Pos)
  74. end
  75.  
  76. function CloseAtticDoor()
  77. local Info = {Time = 0.7, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  78. local Pos = Door.PrimaryPart.CFrame
  79. TweenModel(Door, Info, Pos)
  80. wait(0.7)
  81. local Info = {Time = 0.6, Style = Enum.EasingStyle.Quad, Direction = Enum.EasingDirection.Out}
  82. local Pos = OriginalCFrames.Knobs
  83. TweenModel(DoorObjects.Knobs, Info, Pos)
  84. local Info = {Time = 0.6, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  85. local Pos = OriginalCFrames.Rope
  86. TweenModel(DoorObjects.Rope, Info, Pos)
  87. wait(.5)
  88. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  89. local Pos = OriginalCFrames.Ladder1
  90. TweenModel(DoorObjects.Ladder1, Info, Pos)
  91. wait(.5)
  92. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  93. local Pos = OriginalCFrames.Ladder2
  94. TweenModel(DoorObjects.Ladder2, Info, Pos)
  95. wait(.5)
  96. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  97. local Pos = OriginalCFrames.Ladder3
  98. TweenModel(DoorObjects.Ladder3, Info, Pos)
  99. end
  100.  
  101. function Locked()
  102. local Info = {Time = 0.1, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out, Repeat = 3, Reverse = true}
  103. local Pos = OriginalCFrames.Knobs * CFrame.Angles(math.rad(35), 0, 0)
  104. TweenModel(DoorObjects.Knobs, Info, Pos)
  105. end
  106.  
  107. function CrankRotate1()
  108. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  109. local Pos = OriginalCFrames.LockModel * CFrame.Angles(math.rad(90), 0, 0)
  110. TweenModel(DoorObjects.LockModel, Info, Pos)
  111. end
  112.  
  113. function CrankRotate2()
  114. local Info = {Time = 0.4, Style = Enum.EasingStyle.Sine, Direction = Enum.EasingDirection.Out}
  115. local Pos = OriginalCFrames.LockModel
  116. TweenModel(DoorObjects.LockModel, Info, Pos)
  117. end
  118.  
  119. for i, v in pairs(Door:GetDescendants()) do
  120. if v:IsA("ClickDetector") and v.Name == "OpenCloseLockableDoor" then
  121. v.MouseClick:Connect(function(Player)
  122. if Busy.Value then return end
  123. if State.Value ~= "Locked" then
  124. if State.Value ~= "Open" then
  125. if State.Value == "Close" then
  126. State.Value = "Open"
  127. Busy.Value = true
  128. print("opening door function, name: " .. script.Name .. ".lua")
  129. coroutine.wrap(OpenAtticDoor)()
  130. wait(0.8)
  131. Busy.Value = false
  132. end
  133. end
  134. elseif State.Value ~= "Close" then
  135. if State.Value == "Open" then
  136. Busy.Value = true
  137. State.Value = "Close"
  138. print("closing door function, name: " .. script.Name .. ".lua")
  139. coroutine.wrap(CloseAtticDoor)()
  140. wait(1.6)
  141. Busy.Value = false
  142. end
  143. elseif State.Value ~= "Open" then
  144. if State.Value == "Locked" then
  145. Busy.Value = true
  146. coroutine.wrap(Locked)()
  147. print("locked door function, name: " .. script.Name .. ".lua")
  148. wait(0.8)
  149. Busy.Value = false
  150. end
  151. end
  152. end)
  153. end
  154. end
  155.  
  156. for i, v in pairs(Door:GetDescendants()) do
  157. if v:IsA("ClickDetector") and v.Name == "ToggleLock" then
  158. v.MouseClick:Connect(function(Player)
  159. if Busy.Value then return end
  160. if State.Value ~= "Locked" then
  161. if State.Value ~= "Open" then
  162. if State.Value == "Close" then
  163. State.Value = "Locked"
  164. CrankRotate1()
  165. Busy.Value = true
  166. wait(0.45)
  167. Busy.Value = false
  168. end
  169. end
  170. elseif State.Value == "Locked" then
  171. if State.Value ~= "Open" then
  172. State.Value = "Close"
  173. CrankRotate2()
  174. Busy.Value = true
  175. wait(0.45)
  176. Busy.Value = false
  177. end
  178. end
  179. end)
  180. end
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement