Mrtomtomon

Untitled

Dec 14th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local scale = 1
  2. local thickness = 0.1
  3. local offset = CFrame.new(0, 3*scale + thickness/2, 0)
  4.  
  5. local rad = math.rad
  6.  
  7.  
  8. local Animations = {
  9.     closed = offset * CFrame.new(0, (3*scale + thickness/2), 0),
  10.     opened = offset * CFrame.new(3*scale - thickness/2, 6*scale, 0) *CFrame.Angles(0, 0, -rad(90)),
  11. }
  12.  
  13.  
  14.  
  15. local Container = Instance.new("Model")
  16.  
  17. local function newFace(name)
  18.     local Part = Instance.new("Part")
  19.     Part.Name = name
  20.     Part.TopSurface = Enum.SurfaceType.Smooth
  21.     Part.BottomSurface = Enum.SurfaceType.Smooth
  22.     Part.Anchored = true
  23.     Part.Locked = true
  24.     Part.BrickColor = BrickColor.new("Dirt brown")
  25.     Part.Material = Enum.Material.WoodPlanks
  26.     Part.Parent = Container
  27.     return Part
  28. end
  29.  
  30. local Playing = false
  31. local CurrentAnimation = "closed"
  32.  
  33.  
  34. local Top = newFace("Top")
  35. Top.Size = Vector3.new(6*scale, 0.3, 6*scale)
  36. Top.CFrame = Animations.closed
  37.  
  38. local ClickDetector = Instance.new("ClickDetector")
  39. ClickDetector.Parent = Top
  40.  
  41. ClickDetector.MouseClick:connect(function(player)
  42.     if not Playing then
  43.         Playing = true
  44.         if CurrentAnimation == "closed" then
  45.             for i = 1, 60 do
  46.                 Top.CFrame = Top.CFrame:lerp(Animations.opened, i/60)
  47.                 wait()
  48.             end
  49.             CurrentAnimation = "opened"
  50.         else
  51.             for i = 1, 60 do
  52.                 Top.CFrame = Top.CFrame:lerp(Animations.closed, i/60)
  53.                 wait()
  54.             end
  55.             CurrentAnimation = "closed"
  56.         end
  57.         Playing = false
  58.     end
  59. end)
  60.  
  61.  
  62. local Bottom = newFace("Bottom")
  63. Bottom.Size = Vector3.new(6*scale, thickness, 6*scale)
  64. Bottom.CFrame = offset * CFrame.new(0, -(3*scale + thickness/2), 0)
  65.  
  66. local Left = newFace("Left")
  67. Left.Size = Vector3.new(6*scale, 6*scale, thickness)
  68. Left.CFrame = offset * CFrame.new(0, 0, -(3*scale - thickness/2))
  69.  
  70. local Right = newFace("Right")
  71. Right.Size = Vector3.new(6*scale, 6*scale, thickness)
  72. Right.CFrame = offset * CFrame.new(0, 0, (3*scale - thickness/2))
  73.  
  74.  
  75. local Front = newFace("Front")
  76. Front.Size = Vector3.new(thickness, 6*scale, 6*scale)
  77. Front.CFrame = offset * CFrame.new((3*scale - thickness/2), 0, 0)
  78.  
  79. local Back = newFace("Back")
  80. Back.Size = Vector3.new(thickness, 6*scale, 6*scale)
  81. Back.CFrame = offset * CFrame.new(-(3*scale - thickness/2), 0, 0)
  82.  
  83. Container.Parent = workspace
Advertisement
Add Comment
Please, Sign In to add comment