Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --By solidgoldbrandon (Roblox_SCRIPT_BUILD)
- numberofrainspawned = 9999999999 --number of rains spawned, also affects duration
- rainspawnsaround = CFrame.new(0,250,0) --cframe position where the rain spawns around
- range = 201 --the max distance from the rainspawnaround point where rain spawns
- ---script below---
- function ggwp(thingy)
- thingy.Touched:connect(function (hit)
- if thingy then
- p = thingy --Part which will be cut around
- base = hit --Part which is cut out
- p.CFrame = (base.CFrame - base.CFrame.p) + Vector3.new(p.Position.X, base.Position.Y, p.Position.Z)
- overlappingparts = {}
- cutout = {}
- function Get(Brick)
- if Brick.className == "Part" and Brick ~= p then
- if Brick.Anchored == true then
- xoverlapping = false
- yoverlapping = false
- zoverlapping = false
- ---x---
- x1 = (p.Position.X) - (p.Size.X/2)
- x2 = (p.Position.X) + (p.Size.X/2)
- xx1 = (Brick.Position.X) - (Brick.Size.X/2)
- xx2 = (Brick.Position.X) + (Brick.Size.X/2)
- if xx1 >= x1 and xx1 <= x2 or xx2 >= x1 and xx2 <= x2 or xx1 <= x1 and xx2 >= x2 then
- xoverlapping = true
- end
- -------
- ---y---
- y1 = (p.Position.Y) - (p.Size.Y/2)
- y2 = (p.Position.Y) + (p.Size.Y/2)
- yy1 = (Brick.Position.Y) - (Brick.Size.Y/2)
- yy2 = (Brick.Position.Y) + (Brick.Size.Y/2)
- if yy1 >= y1 and yy1 <= y2 or yy2 >= y1 and yy2 <= y2 or yy1 <= y1 and yy2 >= y2 then
- yoverlapping = true
- end
- -------
- ---z---
- z1 = (p.Position.Z) - (p.Size.Z/2)
- z2 = (p.Position.Z) + (p.Size.Z/2)
- zz1 = (Brick.Position.Z) - (Brick.Size.Z/2)
- zz2 = (Brick.Position.Z) + (Brick.Size.Z/2)
- if zz1 >= z1 and zz1 <= z2 or zz2 >= z1 and zz2 <= z2 or zz1 <= z1 and zz2 >= z2 then
- zoverlapping = true
- end
- -------
- if xoverlapping == true and yoverlapping == true and zoverlapping == true then
- ---overlapzone parts---
- part = Instance.new("Part") --takes up the space overlapped in
- part.BrickColor = BrickColor.Red()
- part.FormFactor = "Custom"
- part.Anchored = true
- if yy1 <= y1 and yy2 >= y2 then
- y = p.Size.Y
- yy = p.Position.Y
- elseif yy1 >= y1 and yy1 <= y2 and yy2 >= y1 and yy2 <= y2 then
- y = Brick.Size.Y
- yy = Brick.Position.Y
- elseif yy1 >= y1 and yy1 <= y2 then
- y = y2-yy1
- yy = y2-y/2
- elseif yy2 >= y1 and yy2 <= y2 then
- y = yy2-y1
- yy = y1+y/2
- end
- if xx1 <= x1 and xx2 >= x2 then
- x = p.Size.X
- xx = p.Position.X
- elseif xx1 >= x1 and xx1 <= x2 and xx2 >= x1 and xx2 <= x2 then
- x = Brick.Size.X
- xx = Brick.Position.X
- elseif xx1 >= x1 and xx1 <= x2 then
- x = x2-xx1
- xx = x2-x/2
- elseif xx2 >= x1 and xx2 <= x2 then
- x = xx2-x1
- xx = x1+x/2
- end
- if zz1 <= z1 and zz2 >= z2 then
- z = p.Size.Z
- zz = p.Position.Z
- elseif zz1 >= z1 and zz1 <= z2 and zz2 >= z1 and zz2 <= z2 then
- z = Brick.Size.Z
- zz = Brick.Position.Z
- elseif zz1 >= z1 and zz1 <= z2 then
- z = z2-zz1
- zz = z2-z/2
- elseif zz2 >= z1 and zz2 <= z2 then
- z = zz2-z1
- zz = z1+z/2
- end
- part.Size = Vector3.new(x,y,z)
- part.CFrame = p.CFrame - p.CFrame.p + Vector3.new(xx,yy,zz) --adaptational rotation
- -----------------------
- table.insert(overlappingparts, Brick)
- table.insert(cutout, part)
- end
- end
- end
- end
- function Search(Object)
- coroutine.resume(coroutine.create(Get), Object)
- local Children = Object:GetChildren()
- for X = 1, #Children do
- Search(Children[X])
- end
- end
- Search(Workspace)
- function MakeHole(p, base)
- b1 = nil
- b2 = nil
- b3 = nil
- b4 = nil
- p.CFrame = (base.CFrame - base.CFrame.p) + Vector3.new(p.Position.X, base.Position.Y, p.Position.Z)
- --X linings
- x = ((base.Size.X - p.Size.X)/ 2) - (p.Position.X - base.Position.X)
- y = (base.Size.Y)
- z = (p.Size.z)
- if x >= 1 and x <= base.Size.X - p.Size.X + 1 then
- b1 = base:Clone()
- b1.FormFactor = "Custom"
- b1.Parent = base.Parent
- b1.Size = Vector3.new(x, y, z)
- b1.CFrame = p.CFrame
- b1.CFrame = p.CFrame * CFrame.new(((x/2)+p.Size.X/2), 0, 0)
- b1.Name = "" ..base.Name .."X1"
- end
- x = ((base.Size.X - p.Size.X)/ 2) + (p.Position.X - base.Position.X)
- if x >= 1 and x <= base.Size.X - p.Size.X + 1 then
- b2 = base:Clone()
- b2.FormFactor = "Custom"
- b2.Parent = base.Parent
- b2.Name = "" ..base.Name .."X2"
- b2.Size = Vector3.new(x, y, z)
- b2.CFrame = p.CFrame
- b2.CFrame = p.CFrame * CFrame.new(-((x/2)+p.Size.X/2), 0, 0)
- end
- --Z linings
- x = (p.Size.X)
- y = (base.Size.Y)
- z = ((base.Size.Z - p.Size.Z)/ 2) - (p.Position.Z - base.Position.Z)
- if z >= 1 and z <= base.Size.Z - p.Size.Z + 1 then
- b3 = base:Clone()
- b3.FormFactor = "Custom"
- b3.Parent = base.Parent
- b3.Name = "" ..base.Name .."Z1"
- b3.Size = Vector3.new(x, y, z)
- b3.CFrame = p.CFrame
- b3.CFrame = p.CFrame * CFrame.new(0, 0, ((z/2)+p.Size.Z/2))
- end
- z = ((base.Size.Z - p.Size.Z)/ 2) + (p.Position.Z - base.Position.Z)
- if z >= 1 and z <= base.Size.Z - p.Size.Z + 1 then
- b4 = base:Clone()
- b4.FormFactor = "Custom"
- b4.Parent = base.Parent
- b4.Name = "" ..base.Name .."Z2"
- b4.Size = Vector3.new(x, y, z)
- b4.CFrame = p.CFrame
- b4.CFrame = p.CFrame * CFrame.new(0, 0, -((z/2)+p.Size.Z/2))
- end
- ---complex parts---
- if b1 and b3 then
- q1 = b1:Clone()
- q1.FormFactor = "Custom"
- q1.Name = "" ..base.Name .. "Q1"
- q1.Parent = base.Parent
- q1.Size = Vector3.new(b1.Size.X, b1.Size.Y, b3.Size.Z)
- q1.CFrame = b1.CFrame
- q1.CFrame = b1.CFrame * CFrame.new(0,0,(b3.Size.Z/2)+b1.Size.Z/2)
- end
- if b1 and b4 then
- q2 = b1:Clone()
- q2.FormFactor = "Custom"
- q2.Name = "" ..base.Name .. "Q2"
- q2.Parent = base.Parent
- q2.Size = Vector3.new(b1.Size.X, b1.Size.Y, b4.Size.Z)
- q2.CFrame = b1.CFrame
- q2.CFrame = b1.CFrame * CFrame.new(0,0,-((b4.Size.Z/2)+b1.Size.Z/2))
- end
- if b2 and b3 then
- q3 = b2:Clone()
- q3.FormFactor = "Custom"
- q3.Name = "" ..base.Name .. "Q3"
- q3.Parent = base.Parent
- q3.Size = Vector3.new(b2.Size.X, b2.Size.Y, b3.Size.Z)
- q3.CFrame = b2.CFrame
- q3.CFrame = b2.CFrame * CFrame.new(0,0,(b3.Size.Z/2)+b2.Size.Z/2)
- end
- if b2 and b4 then
- q4 = b2:Clone()
- q4.FormFactor = "Custom"
- q4.Name = "" ..base.Name .. "Q4"
- q4.Parent = base.Parent
- q4.Size = Vector3.new(b2.Size.X, b2.Size.Y, b4.Size.Z)
- q4.CFrame = b2.CFrame
- q4.CFrame = b2.CFrame * CFrame.new(0,0,-((b4.Size.Z/2)+b2.Size.Z/2))
- end
- -------------------
- base:remove()
- end
- for i=1,#overlappingparts do
- MakeHole(cutout[i], overlappingparts[i])
- end
- p:remove()
- end end)
- end
- for i=1,numberofrainspawned do
- wait(math.random(1,2)/5)
- rain = Instance.new("Part", Workspace)
- rain.Size = Vector3.new(1,1,1)
- rain.TopSurface = 0
- rain.BottomSurface = 0
- rain.Shape = "Ball"
- rain.BrickColor = BrickColor.new("Camo")
- rain.CanCollide = false
- rain.Size = Vector3.new(math.random(15,25),math.random(15,25),math.random(15,25))
- rain.CFrame = rainspawnsaround * CFrame.new(math.random(-range,range),math.random(-100,200),math.random(-range,range))
- s = Instance.new("Sound", rain)
- s.Volume = 1
- s.Pitch = 1
- s.SoundId = "http://www.roblox.com/asset/?version=1&id=154955269"
- s.PlayOnRemove = true
- oh = coroutine.wrap(ggwp)
- oh(rain)
- end
Add Comment
Please, Sign In to add comment