Advertisement
Descaii

Crawler

Mar 21st, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.78 KB | None | 0 0
  1. function GetRecursiveChildren(Place)
  2.     local Stuff = {}
  3.     function GRC(P)
  4.         for i,v in pairs(P:GetChildren()) do
  5.             ypcall(function()
  6.                 GRC(v)
  7.                 table.insert(Stuff,v)
  8.             end)
  9.         end
  10.     end
  11.     GRC(Place)
  12.     GRC = nil
  13.     return Stuff
  14. end
  15. Mouse = game.Players.LocalPlayer:GetMouse()
  16. function Fracture(Spot)
  17.     local Pts = {}
  18.     local AllPts = {}
  19.     local Parts = {}
  20.     local Rays = {}
  21.     local Found = true
  22.     local WPts = GetRecursiveChildren(Workspace)
  23.     Workspace.DescendantAdded:connect(function(v)
  24.         wait()
  25.         if not v:IsDescendantOf(game.Players.LocalPlayer.Character) and v.Name ~= "Base" then
  26.             local F = true
  27.             for i,g in pairs(game.Players:GetPlayers()) do
  28.                 if v:IsDescendantOf(g.Character) then
  29.                     F = false
  30.                 end
  31.             end
  32.             if F then
  33.                 table.insert(WPts,v)
  34.             end
  35.         end
  36.     end)
  37.     table.insert(Pts,Spot)
  38.     repeat wait(0.5)
  39.         --print("one")
  40.         wait(0.1)
  41.         local F = false
  42.     --  print("loop start")
  43.         wait(0.1)
  44.         local PTS2 = {}
  45.         for i,v in pairs(WPts) do
  46.             if not v:IsDescendantOf(Workspace) then
  47.                 table.remove(WPts,i)
  48.             end
  49.         end
  50.         for i,v in pairs(Pts) do
  51.             wait()
  52.             --print("Searching " ..tostring(v))
  53.             for _,g in pairs(WPts) do
  54.                 local PF = false
  55.                 for c,d in pairs(Parts) do
  56.                     if d == g then
  57.                         PF = true
  58.                     end
  59.                 end
  60.                 for z,t in pairs(game.Players:GetPlayers()) do
  61.                     if g:IsDescendantOf(t.Character) then
  62.                         PF = true
  63.                     end
  64.                 end
  65.                 if g.Name == "Base" then
  66.                     PF = true
  67.                 end
  68.                 if not g:IsDescendantOf(game.Players.LocalPlayer.Character) and not PF then
  69.                     ypcall(function()
  70.                         if (v-g.Position).magnitude < 20 and g.Name ~= "Base" then
  71.                             F = true
  72.                             table.insert(PTS2,g.Position)
  73.                             table.insert(AllPts,g.Position)
  74.                             table.insert(Parts,g)
  75.                             g.Anchored = true
  76.                             local Ray = Instance.new("Part",game.Players.LocalPlayer.Character)
  77.                             Ray.Anchored = true
  78.                             local Dis = (v-g.Position).magnitude
  79.                             Ray.FormFactor = "Custom"
  80.                             Ray.Size = Vector3.new(0.5,0.5,Dis)
  81.                             Ray.CanCollide = false
  82.                             Ray.CFrame = CFrame.new(v,g.Position)*CFrame.new(0,0,-Dis/2)
  83.                             Ray.TopSurface = "Smooth"
  84.                             Ray.BottomSurface = "Smooth"
  85.                             Ray.BrickColor = BrickColor.new("Black")
  86.                             table.insert(Rays,Ray)
  87.                         end
  88.                     end)
  89.                 end
  90.             end
  91.         end
  92.         Pts = PTS2
  93.         print("loop end")
  94.         if not F then
  95.             Found = false
  96.         end
  97.     until not Found
  98.     for i,v in pairs(Rays) do
  99.         v:Destroy()
  100.     end
  101.     for i,v in pairs(Parts) do
  102.         if v.Name ~= "Base" then
  103.             v.Anchored = false
  104.             v:breakJoints()
  105.         end
  106.     end
  107.     for i,v in pairs(AllPts) do
  108.         local a = Instance.new("Explosion",Workspace)
  109.         a.Position = v
  110.         a.BlastRadius = 20
  111.         a.DestroyJointRadiusPercent = 0
  112.     end
  113. end
  114. game.Players.LocalPlayer:GetMouse().Button1Down:connect(function()
  115.     Fracture(Mouse.Hit.p)
  116. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement