Advertisement
MLGMatthew

ROBLOX Acid Rain Script

Mar 4th, 2016
1,353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  1. --By "Paste Bin/MlgMatthew","Roblox/Vfen"
  2.  
  3. numberofrainspawned = 9999999999 --number of rains spawned, also affects duration
  4. rainspawnsaround = CFrame.new(0,250,0) --cframe position where the rain spawns around
  5. range = 201 --the max distance from the rainspawnaround point where rain spawns
  6.  
  7.  
  8. ---script below---
  9. function ggwp(thingy)
  10. thingy.Touched:connect(function (hit)
  11. if thingy then
  12. p = thingy --Part which will be cut around
  13.  
  14. base = hit --Part which is cut out
  15. p.CFrame = (base.CFrame - base.CFrame.p) + Vector3.new(p.Position.X, base.Position.Y, p.Position.Z)
  16.  
  17. overlappingparts = {}
  18. cutout = {}
  19.  
  20. function Get(Brick)
  21. if Brick.className == "Part" and Brick ~= p then
  22. if Brick.Anchored == true then
  23. xoverlapping = false
  24. yoverlapping = false
  25. zoverlapping = false
  26. ---x---
  27. x1 = (p.Position.X) - (p.Size.X/2)
  28. x2 = (p.Position.X) + (p.Size.X/2)
  29.  
  30. xx1 = (Brick.Position.X) - (Brick.Size.X/2)
  31. xx2 = (Brick.Position.X) + (Brick.Size.X/2)
  32. if xx1 >= x1 and xx1 <= x2 or xx2 >= x1 and xx2 <= x2 or xx1 <= x1 and xx2 >= x2 then
  33. xoverlapping = true
  34. end
  35. -------
  36. ---y---
  37. y1 = (p.Position.Y) - (p.Size.Y/2)
  38. y2 = (p.Position.Y) + (p.Size.Y/2)
  39.  
  40. yy1 = (Brick.Position.Y) - (Brick.Size.Y/2)
  41. yy2 = (Brick.Position.Y) + (Brick.Size.Y/2)
  42. if yy1 >= y1 and yy1 <= y2 or yy2 >= y1 and yy2 <= y2 or yy1 <= y1 and yy2 >= y2 then
  43. yoverlapping = true
  44. end
  45. -------
  46. ---z---
  47. z1 = (p.Position.Z) - (p.Size.Z/2)
  48. z2 = (p.Position.Z) + (p.Size.Z/2)
  49.  
  50. zz1 = (Brick.Position.Z) - (Brick.Size.Z/2)
  51. zz2 = (Brick.Position.Z) + (Brick.Size.Z/2)
  52. if zz1 >= z1 and zz1 <= z2 or zz2 >= z1 and zz2 <= z2 or zz1 <= z1 and zz2 >= z2 then
  53. zoverlapping = true
  54. end
  55. -------
  56. if xoverlapping == true and yoverlapping == true and zoverlapping == true then
  57. ---overlapzone parts---
  58. part = Instance.new("Part") --takes up the space overlapped in
  59. part.BrickColor = BrickColor.Red()
  60. part.FormFactor = "Custom"
  61. part.Anchored = true
  62. if yy1 <= y1 and yy2 >= y2 then
  63. y = p.Size.Y
  64. yy = p.Position.Y
  65. elseif yy1 >= y1 and yy1 <= y2 and yy2 >= y1 and yy2 <= y2 then
  66. y = Brick.Size.Y
  67. yy = Brick.Position.Y
  68. elseif yy1 >= y1 and yy1 <= y2 then
  69. y = y2-yy1
  70. yy = y2-y/2
  71. elseif yy2 >= y1 and yy2 <= y2 then
  72. y = yy2-y1
  73. yy = y1+y/2
  74. end
  75.  
  76. if xx1 <= x1 and xx2 >= x2 then
  77. x = p.Size.X
  78. xx = p.Position.X
  79. elseif xx1 >= x1 and xx1 <= x2 and xx2 >= x1 and xx2 <= x2 then
  80. x = Brick.Size.X
  81. xx = Brick.Position.X
  82. elseif xx1 >= x1 and xx1 <= x2 then
  83. x = x2-xx1
  84. xx = x2-x/2
  85. elseif xx2 >= x1 and xx2 <= x2 then
  86. x = xx2-x1
  87. xx = x1+x/2
  88. end
  89.  
  90. if zz1 <= z1 and zz2 >= z2 then
  91. z = p.Size.Z
  92. zz = p.Position.Z
  93. elseif zz1 >= z1 and zz1 <= z2 and zz2 >= z1 and zz2 <= z2 then
  94. z = Brick.Size.Z
  95. zz = Brick.Position.Z
  96. elseif zz1 >= z1 and zz1 <= z2 then
  97. z = z2-zz1
  98. zz = z2-z/2
  99. elseif zz2 >= z1 and zz2 <= z2 then
  100. z = zz2-z1
  101. zz = z1+z/2
  102. end
  103.  
  104. part.Size = Vector3.new(x,y,z)
  105. part.CFrame = p.CFrame - p.CFrame.p + Vector3.new(xx,yy,zz) --adaptational rotation
  106. -----------------------
  107. table.insert(overlappingparts, Brick)
  108. table.insert(cutout, part)
  109. end
  110. end
  111. end
  112. end
  113.  
  114. function Search(Object)
  115. coroutine.resume(coroutine.create(Get), Object)
  116. local Children = Object:GetChildren()
  117. for X = 1, #Children do
  118. Search(Children[X])
  119. end
  120. end
  121.  
  122.  
  123. Search(Workspace)
  124.  
  125.  
  126. function MakeHole(p, base)
  127. b1 = nil
  128. b2 = nil
  129. b3 = nil
  130. b4 = nil
  131. p.CFrame = (base.CFrame - base.CFrame.p) + Vector3.new(p.Position.X, base.Position.Y, p.Position.Z)
  132. --X linings
  133. x = ((base.Size.X - p.Size.X)/ 2) - (p.Position.X - base.Position.X)
  134. y = (base.Size.Y)
  135. z = (p.Size.z)
  136.  
  137. if x >= 1 and x <= base.Size.X - p.Size.X + 1 then
  138. b1 = base:Clone()
  139. b1.FormFactor = "Custom"
  140. b1.Parent = base.Parent
  141. b1.Size = Vector3.new(x, y, z)
  142. b1.CFrame = p.CFrame
  143. b1.CFrame = p.CFrame * CFrame.new(((x/2)+p.Size.X/2), 0, 0)
  144. b1.Name = "" ..base.Name .."X1"
  145. end
  146. x = ((base.Size.X - p.Size.X)/ 2) + (p.Position.X - base.Position.X)
  147.  
  148. if x >= 1 and x <= base.Size.X - p.Size.X + 1 then
  149. b2 = base:Clone()
  150. b2.FormFactor = "Custom"
  151. b2.Parent = base.Parent
  152. b2.Name = "" ..base.Name .."X2"
  153. b2.Size = Vector3.new(x, y, z)
  154. b2.CFrame = p.CFrame
  155. b2.CFrame = p.CFrame * CFrame.new(-((x/2)+p.Size.X/2), 0, 0)
  156. end
  157.  
  158. --Z linings
  159. x = (p.Size.X)
  160. y = (base.Size.Y)
  161. z = ((base.Size.Z - p.Size.Z)/ 2) - (p.Position.Z - base.Position.Z)
  162. if z >= 1 and z <= base.Size.Z - p.Size.Z + 1 then
  163. b3 = base:Clone()
  164. b3.FormFactor = "Custom"
  165. b3.Parent = base.Parent
  166. b3.Name = "" ..base.Name .."Z1"
  167. b3.Size = Vector3.new(x, y, z)
  168. b3.CFrame = p.CFrame
  169. b3.CFrame = p.CFrame * CFrame.new(0, 0, ((z/2)+p.Size.Z/2))
  170. end
  171. z = ((base.Size.Z - p.Size.Z)/ 2) + (p.Position.Z - base.Position.Z)
  172. if z >= 1 and z <= base.Size.Z - p.Size.Z + 1 then
  173. b4 = base:Clone()
  174. b4.FormFactor = "Custom"
  175. b4.Parent = base.Parent
  176. b4.Name = "" ..base.Name .."Z2"
  177. b4.Size = Vector3.new(x, y, z)
  178. b4.CFrame = p.CFrame
  179. b4.CFrame = p.CFrame * CFrame.new(0, 0, -((z/2)+p.Size.Z/2))
  180. end
  181. ---complex parts---
  182. if b1 and b3 then
  183. q1 = b1:Clone()
  184. q1.FormFactor = "Custom"
  185. q1.Name = "" ..base.Name .. "Q1"
  186. q1.Parent = base.Parent
  187. q1.Size = Vector3.new(b1.Size.X, b1.Size.Y, b3.Size.Z)
  188. q1.CFrame = b1.CFrame
  189. q1.CFrame = b1.CFrame * CFrame.new(0,0,(b3.Size.Z/2)+b1.Size.Z/2)
  190. end
  191. if b1 and b4 then
  192. q2 = b1:Clone()
  193. q2.FormFactor = "Custom"
  194. q2.Name = "" ..base.Name .. "Q2"
  195. q2.Parent = base.Parent
  196. q2.Size = Vector3.new(b1.Size.X, b1.Size.Y, b4.Size.Z)
  197. q2.CFrame = b1.CFrame
  198. q2.CFrame = b1.CFrame * CFrame.new(0,0,-((b4.Size.Z/2)+b1.Size.Z/2))
  199. end
  200. if b2 and b3 then
  201. q3 = b2:Clone()
  202. q3.FormFactor = "Custom"
  203. q3.Name = "" ..base.Name .. "Q3"
  204. q3.Parent = base.Parent
  205. q3.Size = Vector3.new(b2.Size.X, b2.Size.Y, b3.Size.Z)
  206. q3.CFrame = b2.CFrame
  207. q3.CFrame = b2.CFrame * CFrame.new(0,0,(b3.Size.Z/2)+b2.Size.Z/2)
  208. end
  209. if b2 and b4 then
  210. q4 = b2:Clone()
  211. q4.FormFactor = "Custom"
  212. q4.Name = "" ..base.Name .. "Q4"
  213. q4.Parent = base.Parent
  214. q4.Size = Vector3.new(b2.Size.X, b2.Size.Y, b4.Size.Z)
  215. q4.CFrame = b2.CFrame
  216. q4.CFrame = b2.CFrame * CFrame.new(0,0,-((b4.Size.Z/2)+b2.Size.Z/2))
  217. end
  218. -------------------
  219.  
  220. base:remove()
  221. end
  222.  
  223. for i=1,#overlappingparts do
  224. MakeHole(cutout[i], overlappingparts[i])
  225. end
  226. p:remove()
  227. end end)
  228. end
  229.  
  230. for i=1,numberofrainspawned do
  231. wait(math.random(1,2)/5)
  232. rain = Instance.new("Part", Workspace)
  233. rain.Size = Vector3.new(1,1,1)
  234. rain.TopSurface = 0
  235. rain.BottomSurface = 0
  236. rain.Shape = "Ball"
  237. rain.BrickColor = BrickColor.new("Camo")
  238. rain.CanCollide = false
  239. rain.Size = Vector3.new(math.random(15,25),math.random(15,25),math.random(15,25))
  240. rain.CFrame = rainspawnsaround * CFrame.new(math.random(-range,range),math.random(-100,200),math.random(-range,range))
  241. s = Instance.new("Sound", rain)
  242. s.Volume = 1
  243. s.Pitch = 1
  244. s.SoundId = "http://www.roblox.com/asset/?version=1&id=154955269"
  245. s.PlayOnRemove = true
  246. oh = coroutine.wrap(ggwp)
  247. oh(rain)
  248. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement