Advertisement
BobMe

CRain

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