CHoff719

Box roblox script

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