Pukaciu

ice chest

Aug 10th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. wallWidth = 60
  2. wallHeight = 25
  3. brickSpeed = 0.01
  4.  
  5. brickWidth = 6
  6. brickHeight = 4
  7. brickDepth = 2
  8.  
  9. colors = {BrickColor.new("Medium Blue"), BrickColor.new("Pastel light blue"), BrickColor.new("Light blue"), BrickColor.new("Cyan"), BrickColor.new("Pastel blue")}
  10.  
  11. debris = game:GetService("Debris")
  12.  
  13.  
  14.  
  15.  
  16. local Tool = script.Parent
  17.  
  18. function staffUp()
  19. Tool.GripForward = Vector3.new(0,0,-1)
  20. Tool.GripRight = Vector3.new(1,0,0)
  21. Tool.GripUp = Vector3.new(0,1,0)
  22. end
  23.  
  24. function staffOut()
  25. Tool.GripForward = Vector3.new(.0976, .00976, -.995)
  26. Tool.GripRight = Vector3.new(.195, -.981, .00952)
  27. Tool.GripUp = Vector3.new(.976, .195, .0976)
  28. end
  29.  
  30. -- places a brick at pos and returns the position of the brick's opposite corner
  31. function placeBrick(cf, pos)
  32. local brick = Instance.new("Part")
  33. brick.Size = Vector3.new(brickWidth, brickHeight, brickDepth)
  34. brick.BrickColor = colors[math.random(1, #colors)]
  35. brick.Friction = .01
  36. brick.CFrame = cf * CFrame.new(pos + brick.size / 2)
  37.  
  38. if ( math.random() > .5) then
  39. brick.Material = Enum.Material.Ice
  40. else
  41. brick.Transparency = .1 + (math.random(1,4) / 10)
  42. end
  43.  
  44. brick.Parent = game.Workspace
  45. brick:makeJoints()
  46. debris:AddItem(brick, 120)
  47. return brick, pos + brick.size
  48. end
  49.  
  50. function buildWall(cf)
  51.  
  52. local bricks = {}
  53.  
  54. assert(wallWidth>0)
  55. local y = 0
  56. while y < wallHeight do
  57. local p
  58. local x = -wallWidth/2
  59. while x < wallWidth/2 do
  60. local brick
  61. brick, p = placeBrick(cf, Vector3.new(x, y, 0), color)
  62. x = p.x
  63. table.insert(bricks, brick)
  64. wait(brickSpeed)
  65. end
  66. y = p.y
  67. end
  68.  
  69. return bricks
  70.  
  71. end
  72.  
  73.  
  74. function snap(v)
  75. if math.abs(v.x)>math.abs(v.z) then
  76. if v.x>0 then
  77. return Vector3.new(1,0,0)
  78. else
  79. return Vector3.new(-1,0,0)
  80. end
  81. else
  82. if v.z>0 then
  83. return Vector3.new(0,0,1)
  84. else
  85. return Vector3.new(0,0,-1)
  86. end
  87. end
  88. end
  89.  
  90.  
  91. Tool.Enabled = true
  92. function onActivated()
  93.  
  94. if not Tool.Enabled then
  95. return
  96. end
  97.  
  98. Tool.Enabled = false
  99.  
  100. local character = Tool.Parent;
  101. local humanoid = character.Humanoid
  102. if humanoid == nil then
  103. print("Humanoid not found")
  104. return
  105. end
  106.  
  107. local targetPos = humanoid.TargetPoint
  108. local lookAt = snap( (targetPos - character.Head.Position).unit )
  109. local cf = CFrame.new(targetPos, targetPos + lookAt)
  110.  
  111. if (targetPos - character.Torso.Position).magnitude < 64 then
  112. staffOut()
  113. Tool.Handle.UseSound:Play()
  114. buildWall(cf)
  115. staffUp()
  116. wait(5)
  117. end
  118.  
  119. Tool.Enabled = true
  120. end
  121.  
  122. script.Parent.Activated:connect(onActivated)
  123. local Tool = script.Parent;
  124.  
  125.  
  126. function UpdateIcon(mouse)
  127. if (mouse == nil) then return end
  128. if (Tool.Enabled == true) then
  129. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  130. else
  131. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  132. end
  133. end
  134.  
  135.  
  136. function onButton1Down(mouse)
  137. UpdateIcon(mouse)
  138. end
  139.  
  140. function onEquippedLocal(mouse)
  141.  
  142. UpdateIcon(mouse)
  143. end
  144.  
  145.  
  146. Tool.Equipped:connect(onEquippedLocal)
Add Comment
Please, Sign In to add comment