Advertisement
MyNewName

Untitled

Mar 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.00 KB | None | 0 0
  1.  
  2. --Converted with ttyyuu12345's model to script plugin v4
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. Part1 = Instance.new("Part")
  21. Part2 = Instance.new("Part")
  22. CylinderMesh3 = Instance.new("CylinderMesh")
  23. Smoke4 = Instance.new("Smoke")
  24. Part5 = Instance.new("Part")
  25. Script6 = Instance.new("Script")
  26. ObjectValue7 = Instance.new("ObjectValue")
  27. Animation8 = Instance.new("Animation")
  28. ObjectValue9 = Instance.new("ObjectValue")
  29. LocalScript10 = Instance.new("LocalScript")
  30. ScreenGui11 = Instance.new("ScreenGui")
  31. Frame12 = Instance.new("Frame")
  32. Frame13 = Instance.new("Frame")
  33. TextLabel14 = Instance.new("TextLabel")
  34. NumberValue15 = Instance.new("NumberValue")
  35. Script16 = Instance.new("Script")
  36. Script17 = Instance.new("Script")
  37. Script18 = Instance.new("Script")
  38. Tool19 = Instance.new("Tool")
  39. Part20 = Instance.new("Part")
  40. Part21 = Instance.new("Part")
  41. CylinderMesh22 = Instance.new("CylinderMesh")
  42. Smoke23 = Instance.new("Smoke")
  43. Part24 = Instance.new("Part")
  44. Script25 = Instance.new("Script")
  45. ObjectValue26 = Instance.new("ObjectValue")
  46. Animation27 = Instance.new("Animation")
  47. ObjectValue28 = Instance.new("ObjectValue")
  48. LocalScript29 = Instance.new("LocalScript")
  49. ScreenGui30 = Instance.new("ScreenGui")
  50. Frame31 = Instance.new("Frame")
  51. Frame32 = Instance.new("Frame")
  52. TextLabel33 = Instance.new("TextLabel")
  53. NumberValue34 = Instance.new("NumberValue")
  54. Script35 = Instance.new("Script")
  55. Script36 = Instance.new("Script")
  56. Script37 = Instance.new("Script")
  57. Tool38 = Instance.new("Tool")
  58. Part39 = Instance.new("Part")
  59. Part40 = Instance.new("Part")
  60. CylinderMesh41 = Instance.new("CylinderMesh")
  61. Smoke42 = Instance.new("Smoke")
  62. Part43 = Instance.new("Part")
  63. Script44 = Instance.new("Script")
  64. ObjectValue45 = Instance.new("ObjectValue")
  65. Animation46 = Instance.new("Animation")
  66. ObjectValue47 = Instance.new("ObjectValue")
  67. LocalScript48 = Instance.new("LocalScript")
  68. ScreenGui49 = Instance.new("ScreenGui")
  69. Frame50 = Instance.new("Frame")
  70. Frame51 = Instance.new("Frame")
  71. TextLabel52 = Instance.new("TextLabel")
  72. NumberValue53 = Instance.new("NumberValue")
  73. Script54 = Instance.new("Script")
  74. Script55 = Instance.new("Script")
  75. Script56 = Instance.new("Script")
  76. Tool0.Name = "Dig"
  77. Tool0.Parent = mas
  78. Part1.Name = "Shaft"
  79. Part1.Parent = Tool0
  80. Part1.BrickColor = BrickColor.new("Brown")
  81. Part1.Transparency = 1
  82. Part1.Rotation = Vector3.new(90, 0, 180)
  83. Part1.CanCollide = false
  84. Part1.Size = Vector3.new(1, 1.20000005, 1)
  85. Part1.CFrame = CFrame.new(-0.190005645, 3.27113247, -51.3199501, -1, -8.85545069e-06, 2.26416751e-06, -2.26409475e-06, -8.40721441e-06, -1, 8.85547615e-06, -1, 8.40720077e-06)
  86. Part1.BackSurface = Enum.SurfaceType.Weld
  87. Part1.BottomSurface = Enum.SurfaceType.Weld
  88. Part1.FrontSurface = Enum.SurfaceType.Weld
  89. Part1.LeftSurface = Enum.SurfaceType.Weld
  90. Part1.RightSurface = Enum.SurfaceType.Weld
  91. Part1.TopSurface = Enum.SurfaceType.Weld
  92. Part1.Color = Color3.new(0.486275, 0.360784, 0.27451)
  93. Part1.Position = Vector3.new(-0.190005645, 3.27113247, -51.3199501)
  94. Part1.Orientation = Vector3.new(90, -180, 0)
  95. Part1.Color = Color3.new(0.486275, 0.360784, 0.27451)
  96. Part2.Name = "Dirt"
  97. Part2.Parent = Tool0
  98. Part2.BrickColor = BrickColor.new("Dark stone grey")
  99. Part2.Transparency = 1
  100. Part2.Rotation = Vector3.new(0, -0.0199999996, 180)
  101. Part2.CanCollide = false
  102. Part2.Size = Vector3.new(1, 1.20000005, 1)
  103. Part2.CFrame = CFrame.new(-0.190016598, 6.17117882, -51.3199501, -0.99999994, -2.10918824e-06, -0.000354161253, 2.11217753e-06, -1, -8.70998429e-06, -0.000354160846, -8.71034808e-06, 0.99999994)
  104. Part2.BackSurface = Enum.SurfaceType.Weld
  105. Part2.BottomSurface = Enum.SurfaceType.Weld
  106. Part2.FrontSurface = Enum.SurfaceType.Weld
  107. Part2.LeftSurface = Enum.SurfaceType.Weld
  108. Part2.RightSurface = Enum.SurfaceType.Weld
  109. Part2.TopSurface = Enum.SurfaceType.Weld
  110. Part2.Color = Color3.new(0.388235, 0.372549, 0.384314)
  111. Part2.Position = Vector3.new(-0.190016598, 6.17117882, -51.3199501)
  112. Part2.Orientation = Vector3.new(0, -0.0199999996, 180)
  113. Part2.Color = Color3.new(0.388235, 0.372549, 0.384314)
  114. CylinderMesh3.Parent = Part2
  115. CylinderMesh3.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  116. CylinderMesh3.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  117. Smoke4.Parent = Part2
  118. Smoke4.Size = 0.10000000149012
  119. Smoke4.Color = Color3.new(0.372549, 0.211765, 0.121569)
  120. Smoke4.Enabled = false
  121. Smoke4.Opacity = 0.25
  122. Smoke4.RiseVelocity = -0.5
  123. Smoke4.Color = Color3.new(0.372549, 0.211765, 0.121569)
  124. Part5.Name = "Handle"
  125. Part5.Parent = Tool0
  126. Part5.BrickColor = BrickColor.new("Bright green")
  127. Part5.Transparency = 1
  128. Part5.Rotation = Vector3.new(0, 90, 0)
  129. Part5.Size = Vector3.new(1, 1.20000005, 1)
  130. Part5.CFrame = CFrame.new(-0.190006226, 4.37113285, -51.3199577, -8.85535337e-06, -2.26414318e-06, 1, -8.40711709e-06, 1, 2.26411908e-06, -1, -8.40729808e-06, -8.85557347e-06)
  131. Part5.Color = Color3.new(0.294118, 0.592157, 0.294118)
  132. Part5.Position = Vector3.new(-0.190006226, 4.37113285, -51.3199577)
  133. Part5.Orientation = Vector3.new(0, 90, 0)
  134. Part5.Color = Color3.new(0.294118, 0.592157, 0.294118)
  135. Script6.Name = "Weld"
  136. Script6.Parent = Tool0
  137. table.insert(cors,sandbox(Script6,function()
  138. function Weld(x,y)
  139. local W = Instance.new("Weld")
  140. W.Part0 = x
  141. W.Part1 = y
  142. local CJ = CFrame.new(x.Position)
  143. local C0 = x.CFrame:inverse()*CJ
  144. local C1 = y.CFrame:inverse()*CJ
  145. W.C0 = C0
  146. W.C1 = C1
  147. W.Parent = x
  148. end
  149. function Get(A)
  150. if A.className == "Part" then
  151. Weld(script.Parent.Handle, A)
  152. A.Anchored = false
  153. else
  154. local C = A:GetChildren()
  155. for i=1, #C do
  156. Get(C[i])
  157. end
  158. end
  159. end
  160. function Finale()
  161. Get(script.Parent)
  162. end
  163. script.Parent.Equipped:connect(Finale)
  164. script.Parent.Unequipped:connect(Finale)
  165. Finale()
  166.  
  167. end))
  168. ObjectValue7.Name = "DiggyDiggyHole"
  169. ObjectValue7.Parent = Tool0
  170. Animation8.Name = "SlashAnim"
  171. Animation8.Parent = Tool0
  172. Animation8.AnimationId = "http://www.roblox.com/Asset?ID=54673790"
  173. ObjectValue9.Name = "guiObject"
  174. ObjectValue9.Parent = Tool0
  175. LocalScript10.Name = "Dig"
  176. LocalScript10.Parent = Tool0
  177. LocalScript10.Disabled = true
  178. table.insert(cors,sandbox(LocalScript10,function()
  179. wait(1)
  180. enabled = true
  181. Tool = script.Parent
  182. down = false -- Mouse isn't down
  183. gui = script.LoadBar:clone() -- Displays your process in digging
  184.  
  185. -- Cyrion's auto-wedge fcn:
  186. --sets cell x, y, z to default material if parameter is provided, if not sets cell x, y, z to be whatever material it previously was
  187. --returns true if made a wedge, false if the cell remains a block
  188. function MakeWedge(x, y, z, defaultmaterial)
  189. local c = game.Workspace.Terrain
  190. --gather info about all the cells around x, y, z
  191. surroundings = {} --surroundings is a 3 x 3 x 3 array of the material of the cells adjacent to x, y, z
  192. for i = x - 1, x + 1 do
  193. surroundings[i] = {"Water"}
  194. for j = y - 1, y + 1 do
  195. surroundings[i][j] = {}
  196. for k = z - 1, z + 1 do
  197. local material, wedge, rotation = c:GetCell(i, j, k)
  198. surroundings[i][j][k] = material.Value
  199. end
  200. end
  201. end
  202. --make some useful arrays and counters
  203. local sides = {} --sides is an array of the material of the 4 adjacent sides
  204. sides[0] = surroundings[x - 1][y][z]
  205. sides[1] = surroundings[x][y][z + 1]
  206. sides[2] = surroundings[x + 1][y][z]
  207. sides[3] = surroundings[x][y][z - 1]
  208. local adjacentSides = 0
  209. for n = 0, 3 do
  210. if sides[n] > 0 then
  211. adjacentSides = adjacentSides + 1
  212. end
  213. end
  214. local sidesAbove = {} --sides is an array of the material of the 4 adjacent sides 1 height above
  215. sidesAbove[0] = surroundings[x - 1][y + 1][z]
  216. sidesAbove[1] = surroundings[x][y + 1][z + 1]
  217. sidesAbove[2] = surroundings[x + 1][y + 1][z]
  218. sidesAbove[3] = surroundings[x][y + 1][z - 1]
  219. local adjacentSidesAbove = 0
  220. for n = 0, 3 do
  221. if sidesAbove[n] > 0 then
  222. adjacentSidesAbove = adjacentSidesAbove + 1
  223. end
  224. end
  225. local corners = {} --corners is an array of the material of the 4 adjacent corners
  226. corners[0] = surroundings[x - 1][y][z - 1]
  227. corners[1] = surroundings[x - 1][y][z + 1]
  228. corners[2] = surroundings[x + 1][y][z + 1]
  229. corners[3] = surroundings[x + 1][y][z - 1]
  230. local adjacentCorners = 0
  231. for n = 0, 3 do
  232. if corners[n] > 0 then
  233. adjacentCorners = adjacentCorners + 1
  234. end
  235. end
  236. local cornersAbove = {} --corners is an array of the material of the 4 adjacent corners 1 height above
  237. cornersAbove[0] = surroundings[x - 1][y + 1][z - 1]
  238. cornersAbove[1] = surroundings[x - 1][y + 1][z + 1]
  239. cornersAbove[2] = surroundings[x + 1][y + 1][z + 1]
  240. cornersAbove[3] = surroundings[x + 1][y + 1][z - 1]
  241. local adjacentCornersAbove = 0
  242. for n = 0, 3 do
  243. if cornersAbove[n] > 0 then
  244. adjacentCornersAbove = adjacentCornersAbove + 1
  245. end
  246. end
  247. --determine what type of wedge to make
  248. local material = "Water"
  249. local wedge = nil
  250. local rotation = nil
  251. if defaultmaterial then
  252. material = defaultmaterial
  253. else
  254. material, wedge, rotation = c:GetCell(x, y, z) --start with the existing material, wedge, and rotation
  255. end
  256. wedge = 0 --default wedge is a block
  257. rotation = 0 --default rotation is 0
  258. --type 1: 45 degree ramp //must not have a block on top and must have a block under, and be surrounded by 1 side; or 3 sides and the 2 corners between them
  259. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  260. if adjacentSides == 1 then
  261. for n = 0, 3 do
  262. if sides[n] > 0 then
  263. wedge = 1
  264. rotation = (n + 1) % 4
  265. c:SetCell(x, y, z, "Water", "Solid", "Z")
  266. return true
  267. end
  268. end
  269. elseif adjacentSides == 3 then
  270. for n = 0, 3 do
  271. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and corners[(n + 2) % 4] > 0 and sides[(n + 2) % 4] > 0 then
  272. wedge = 1
  273. rotation = (n + 2) % 4
  274. c:SetCell(x, y, z, 0,0,0)
  275. return true
  276. end
  277. end
  278. end
  279. end
  280. --type 2: 45 degree corner //must not have a block on top and must have a block under, and be surrounded by 2 sides and the 1 corner between them; or 3 sides and 1 corner between 2 of them (facing towards that corner)
  281. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  282. for n = 0, 3 do
  283. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and (adjacentSides == 2 or (adjacentSides == 3 and (corners[(n + 3) % 4] > 0 or (sides[(n + 2) % 4] > 0 and corners[(n + 2) % 4] > 0) or (sides[(n + 3) % 4] > 0 and corners[n] > 0)))) then
  284. wedge = 2
  285. rotation = (n + 2) % 4
  286. c:SetCell(x, y, z, 0,0,0)
  287. return true
  288. end
  289. end
  290. end
  291. --type 3: 45 degree inverse corner //surrounded by three sides or 4 sides and 3 corners, with nothing above or else a block on top surrounded on 2 sides and the corner between them
  292. if adjacentSides == 3 and surroundings[x][y + 1][z] > 0 then
  293. if adjacentCorners > 1 then
  294. for n = 0, 3 do
  295. if (corners[n] == 0 or cornersAbove[n] == 0) and (sides[(n - 1) % 4] == 0 or sides[n] == 0) and (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0) then
  296. wedge = 3
  297. rotation = (n + 3) % 4
  298. c:SetCell(x, y, z, 0,0,0)
  299. return true
  300. end
  301. end
  302. end
  303. elseif adjacentSides == 4 and adjacentCorners == 3 then
  304. for n = 0, 3 do
  305. if corners[n] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and cornersAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0)) then
  306. wedge = 3
  307. rotation = (n + 3) % 4
  308. c:SetCell(x, y, z, 0,0,0)
  309. return true
  310. end
  311. end
  312. end
  313. --type 4: half a cube, as if it were cut diagonally from front to back //surrounded by 2 sides
  314. if adjacentSides == 2 and adjacentCorners < 4 then
  315. for n = 0, 3 do
  316. if sides[n] == 0 and sides[(n + 1) % 4] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] == 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] > 0)) then
  317. wedge = 4
  318. rotation = n
  319. c:SetCell(x, y, z, 0,0,0)
  320. return true
  321. end
  322. end
  323. end
  324. c:SetCell(x, y, z, 0,0,0)
  325. return false
  326. end
  327.  
  328. function updateMouseRadius(mouse) -- Makes sure that while the player is digging he doesn't go move his mouse somewhere else going outside our magnitude
  329. p = game.Players.LocalPlayer
  330. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then -- YOU RULE BREAKER!!!
  331. onDeselect() -- Acts as if they stopped holding the mouse down
  332. end
  333. end
  334.  
  335.  
  336.  
  337. function onClick(mouse)
  338. h = game.Players.LocalPlayer.Character.Humanoid
  339. if not enabled or down or h == nil then
  340. return
  341. end
  342. p = game.Players.LocalPlayer
  343. if (p == nil) then return end
  344. if (p.Character == nil) then return end
  345. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then return end
  346. down = true
  347. enabled = false
  348. c = game.Workspace.Terrain
  349. while down do
  350. Tool.Dirt.Smoke.Enabled = true
  351. if not p.PlayerGui:findFirstChild("LoadBar") then
  352. local l = gui:clone()
  353. l.Parent = p.PlayerGui
  354. script.Parent.guiObject.Value = l
  355. end
  356. local guivalue = p.PlayerGui:findFirstChild("LoadBar").Frame.LoadBarPercentage
  357. updateMouseRadius(mouse) -- Checks radius
  358. guivalue.Value = guivalue.Value + 30
  359. if guivalue.Value >= 100 then
  360. local cellPos = c:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
  361. local x = cellPos.x
  362. local y = cellPos.y
  363. local z = cellPos.z
  364. c:SetCell(x, y, z, "Water","Solid",0)
  365. for i = x - 1, x + 1 do
  366. for j = y - 1, y + 1 do
  367. for k = z - 1, z + 1 do
  368. MakeWedge(i, j, k)
  369. end
  370. end
  371. end
  372. Tool.Dirt.Smoke.Enabled = false
  373. onDeselect(mouse) -- Kills GUI
  374. enabled = false
  375. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  376. wait(0.5)
  377. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  378. enabled = true
  379. end
  380. wait()
  381. end
  382. end
  383.  
  384. function onClickOff(mouse)
  385. Tool.Dirt.Smoke.Enabled = false
  386. enabled = true
  387. down = false
  388. if script.Parent.guiObject.Value ~= nil then
  389. script.Parent.guiObject.Value:remove()
  390. end
  391. if Tool.DiggyDiggyHole.Value ~= nil then
  392. Tool.DiggyDiggyHole.Value:Stop()
  393. Tool.DiggyDiggyHole.Value:remove()
  394. end
  395. Tool.GripForward = Vector3.new(0,0,-1)
  396. Tool.GripRight = Vector3.new(0,0,0)
  397. Tool.GripUp = Vector3.new(0, 1, 0)
  398. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  399. Tool.Animate.Disabled = false
  400. end
  401.  
  402. function onDeselect(mouse)
  403. Tool.Dirt.Smoke.Enabled = false
  404. enabled = true
  405. down = false
  406. if script.Parent.guiObject.Value ~= nil then
  407. script.Parent.guiObject.Value:remove()
  408. end
  409. if Tool.DiggyDiggyHole.Value ~= nil then
  410. Tool.DiggyDiggyHole.Value:Stop()
  411. Tool.DiggyDiggyHole.Value:remove()
  412. end
  413. Tool.GripForward = Vector3.new(0,0,-1)
  414. Tool.GripRight = Vector3.new(0,0,0)
  415. Tool.GripUp = Vector3.new(0, 1, 0)
  416. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  417. Tool.Animate.Disabled = false
  418. end
  419.  
  420. function onSelect(mouse)
  421. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  422. mouse.Button1Down:connect(function () onClick(mouse) end)
  423. mouse.Button1Up:connect(function () onClickOff(mouse) end)
  424. end
  425.  
  426.  
  427.  
  428. script.Parent.Equipped:connect(onSelect)
  429. script.Parent.UnEquipped:connect(onDeselect)
  430. end))
  431. ScreenGui11.Name = "LoadBar"
  432. ScreenGui11.Parent = LocalScript10
  433. Frame12.Parent = ScreenGui11
  434. Frame12.Size = UDim2.new(0.375, 0, 0.125, 0)
  435. Frame12.Style = Enum.FrameStyle.RobloxRound
  436. Frame12.Position = UDim2.new(0.625, 0, 0.75, 0)
  437. Frame12.Visible = false
  438. Frame13.Name = "LoadBar"
  439. Frame13.Parent = Frame12
  440. Frame13.Size = UDim2.new(0, 0, 1, 0)
  441. Frame13.Style = Enum.FrameStyle.ChatGreen
  442. TextLabel14.Parent = Frame13
  443. TextLabel14.Text = ""
  444. TextLabel14.Position = UDim2.new(0.5, 0, 0.5, 0)
  445. TextLabel14.Font = Enum.Font.ArialBold
  446. TextLabel14.FontSize = Enum.FontSize.Size24
  447. TextLabel14.TextColor3 = Color3.new(0.6, 0.2, 0)
  448. NumberValue15.Name = "LoadBarPercentage"
  449. NumberValue15.Parent = Frame12
  450. Script16.Parent = NumberValue15
  451. Script16.Disabled = true
  452. table.insert(cors,sandbox(Script16,function()
  453. function UpdateBar()
  454. script.Parent.Parent.LoadBar.Size = UDim2.new((script.Parent.Parent.LoadBarPercentage.Value*.01),0,1,0)
  455. script.Parent.Parent.LoadBar.TextLabel.Text = script.Parent.Parent.LoadBarPercentage.Value.."%"
  456. end
  457.  
  458. script.Parent.Changed:connect(UpdateBar)
  459. end))
  460. Script17.Name = "Debug"
  461. Script17.Parent = Script16
  462. table.insert(cors,sandbox(Script17,function()
  463. -- Online mode is really screwed up :P
  464. wait(1)
  465. script.Parent.Disabled = false
  466. script:remove()
  467. end))
  468. Script18.Name = "Debug"
  469. Script18.Parent = LocalScript10
  470. table.insert(cors,sandbox(Script18,function()
  471. -- Online mode is really screwed up :P
  472. wait(1)
  473. script.Parent.Disabled = false
  474. script:remove()
  475. end))
  476. Tool19.Name = "Terraform"
  477. Tool19.Parent = mas
  478. Part20.Name = "Shaft"
  479. Part20.Parent = Tool19
  480. Part20.BrickColor = BrickColor.new("Brown")
  481. Part20.Transparency = 1
  482. Part20.Rotation = Vector3.new(90, 0, 180)
  483. Part20.CanCollide = false
  484. Part20.Size = Vector3.new(1, 1.20000005, 1)
  485. Part20.CFrame = CFrame.new(-0.190006599, 3.27113295, -51.3199539, -1, -8.85543432e-06, 2.26416341e-06, -2.26409884e-06, -8.40719804e-06, -1, 8.85549252e-06, -1, 8.40721714e-06)
  486. Part20.BackSurface = Enum.SurfaceType.Weld
  487. Part20.BottomSurface = Enum.SurfaceType.Weld
  488. Part20.FrontSurface = Enum.SurfaceType.Weld
  489. Part20.LeftSurface = Enum.SurfaceType.Weld
  490. Part20.RightSurface = Enum.SurfaceType.Weld
  491. Part20.TopSurface = Enum.SurfaceType.Weld
  492. Part20.Color = Color3.new(0.486275, 0.360784, 0.27451)
  493. Part20.Position = Vector3.new(-0.190006599, 3.27113295, -51.3199539)
  494. Part20.Orientation = Vector3.new(90, -180, 0)
  495. Part20.Color = Color3.new(0.486275, 0.360784, 0.27451)
  496. Part21.Name = "Dirt"
  497. Part21.Parent = Tool19
  498. Part21.BrickColor = BrickColor.new("Dark stone grey")
  499. Part21.Transparency = 1
  500. Part21.Rotation = Vector3.new(0, -0.0199999996, 180)
  501. Part21.CanCollide = false
  502. Part21.Size = Vector3.new(1, 1.20000005, 1)
  503. Part21.CFrame = CFrame.new(-0.190016598, 6.17117882, -51.3199501, -0.99999994, -2.10918824e-06, -0.000354161253, 2.11217753e-06, -1, -8.70998429e-06, -0.000354160846, -8.71034808e-06, 0.99999994)
  504. Part21.BackSurface = Enum.SurfaceType.Weld
  505. Part21.BottomSurface = Enum.SurfaceType.Weld
  506. Part21.FrontSurface = Enum.SurfaceType.Weld
  507. Part21.LeftSurface = Enum.SurfaceType.Weld
  508. Part21.RightSurface = Enum.SurfaceType.Weld
  509. Part21.TopSurface = Enum.SurfaceType.Weld
  510. Part21.Color = Color3.new(0.388235, 0.372549, 0.384314)
  511. Part21.Position = Vector3.new(-0.190016598, 6.17117882, -51.3199501)
  512. Part21.Orientation = Vector3.new(0, -0.0199999996, 180)
  513. Part21.Color = Color3.new(0.388235, 0.372549, 0.384314)
  514. CylinderMesh22.Parent = Part21
  515. CylinderMesh22.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  516. CylinderMesh22.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  517. Smoke23.Parent = Part21
  518. Smoke23.Size = 0.10000000149012
  519. Smoke23.Color = Color3.new(0.372549, 0.211765, 0.121569)
  520. Smoke23.Enabled = false
  521. Smoke23.Opacity = 0.25
  522. Smoke23.RiseVelocity = -0.5
  523. Smoke23.Color = Color3.new(0.372549, 0.211765, 0.121569)
  524. Part24.Name = "Handle"
  525. Part24.Parent = Tool19
  526. Part24.BrickColor = BrickColor.new("Bright green")
  527. Part24.Transparency = 1
  528. Part24.Rotation = Vector3.new(0, 90, 0)
  529. Part24.Size = Vector3.new(1, 1.20000005, 1)
  530. Part24.CFrame = CFrame.new(-0.190008134, 4.37113476, -51.3199577, -8.85529607e-06, -2.26412885e-06, 1, -8.40705979e-06, 1, 2.2641334e-06, -1, -8.40735538e-06, -8.85563077e-06)
  531. Part24.Color = Color3.new(0.294118, 0.592157, 0.294118)
  532. Part24.Position = Vector3.new(-0.190008134, 4.37113476, -51.3199577)
  533. Part24.Orientation = Vector3.new(0, 90, 0)
  534. Part24.Color = Color3.new(0.294118, 0.592157, 0.294118)
  535. Script25.Name = "Weld"
  536. Script25.Parent = Tool19
  537. table.insert(cors,sandbox(Script25,function()
  538. function Weld(x,y)
  539. local W = Instance.new("Weld")
  540. W.Part0 = x
  541. W.Part1 = y
  542. local CJ = CFrame.new(x.Position)
  543. local C0 = x.CFrame:inverse()*CJ
  544. local C1 = y.CFrame:inverse()*CJ
  545. W.C0 = C0
  546. W.C1 = C1
  547. W.Parent = x
  548. end
  549. function Get(A)
  550. if A.className == "Part" then
  551. Weld(script.Parent.Handle, A)
  552. A.Anchored = false
  553. else
  554. local C = A:GetChildren()
  555. for i=1, #C do
  556. Get(C[i])
  557. end
  558. end
  559. end
  560. function Finale()
  561. Get(script.Parent)
  562. end
  563. script.Parent.Equipped:connect(Finale)
  564. script.Parent.Unequipped:connect(Finale)
  565. Finale()
  566.  
  567. end))
  568. ObjectValue26.Name = "DiggyDiggyHole"
  569. ObjectValue26.Parent = Tool19
  570. Animation27.Name = "SlashAnim"
  571. Animation27.Parent = Tool19
  572. Animation27.AnimationId = "http://www.roblox.com/Asset?ID=54673790"
  573. ObjectValue28.Name = "guiObject"
  574. ObjectValue28.Parent = Tool19
  575. LocalScript29.Name = "Dig"
  576. LocalScript29.Parent = Tool19
  577. LocalScript29.Disabled = true
  578. table.insert(cors,sandbox(LocalScript29,function()
  579. wait(1)
  580. enabled = true
  581. Tool = script.Parent
  582. down = false -- Mouse isn't down
  583. gui = script.LoadBar:clone() -- Displays your process in digging
  584.  
  585. -- Cyrion's auto-wedge fcn:
  586. --sets cell x, y, z to default material if parameter is provided, if not sets cell x, y, z to be whatever material it previously was
  587. --returns true if made a wedge, false if the cell remains a block
  588. function MakeWedge(x, y, z, defaultmaterial)
  589. local c = game.Workspace.Terrain
  590. --gather info about all the cells around x, y, z
  591. surroundings = {} --surroundings is a 3 x 3 x 3 array of the material of the cells adjacent to x, y, z
  592. for i = x - 1, x + 1 do
  593. surroundings[i] = {"Water"}
  594. for j = y - 1, y + 1 do
  595. surroundings[i][j] = {}
  596. for k = z - 1, z + 1 do
  597. local material, wedge, rotation = c:GetCell(i, j, k)
  598. surroundings[i][j][k] = material.Value
  599. end
  600. end
  601. end
  602. --make some useful arrays and counters
  603. local sides = {} --sides is an array of the material of the 4 adjacent sides
  604. sides[0] = surroundings[x - 1][y][z]
  605. sides[1] = surroundings[x][y][z + 1]
  606. sides[2] = surroundings[x + 1][y][z]
  607. sides[3] = surroundings[x][y][z - 1]
  608. local adjacentSides = 0
  609. for n = 0, 3 do
  610. if sides[n] > 0 then
  611. adjacentSides = adjacentSides + 1
  612. end
  613. end
  614. local sidesAbove = {} --sides is an array of the material of the 4 adjacent sides 1 height above
  615. sidesAbove[0] = surroundings[x - 1][y + 1][z]
  616. sidesAbove[1] = surroundings[x][y + 1][z + 1]
  617. sidesAbove[2] = surroundings[x + 1][y + 1][z]
  618. sidesAbove[3] = surroundings[x][y + 1][z - 1]
  619. local adjacentSidesAbove = 0
  620. for n = 0, 3 do
  621. if sidesAbove[n] > 0 then
  622. adjacentSidesAbove = adjacentSidesAbove + 1
  623. end
  624. end
  625. local corners = {} --corners is an array of the material of the 4 adjacent corners
  626. corners[0] = surroundings[x - 1][y][z - 1]
  627. corners[1] = surroundings[x - 1][y][z + 1]
  628. corners[2] = surroundings[x + 1][y][z + 1]
  629. corners[3] = surroundings[x + 1][y][z - 1]
  630. local adjacentCorners = 0
  631. for n = 0, 3 do
  632. if corners[n] > 0 then
  633. adjacentCorners = adjacentCorners + 1
  634. end
  635. end
  636. local cornersAbove = {} --corners is an array of the material of the 4 adjacent corners 1 height above
  637. cornersAbove[0] = surroundings[x - 1][y + 1][z - 1]
  638. cornersAbove[1] = surroundings[x - 1][y + 1][z + 1]
  639. cornersAbove[2] = surroundings[x + 1][y + 1][z + 1]
  640. cornersAbove[3] = surroundings[x + 1][y + 1][z - 1]
  641. local adjacentCornersAbove = 0
  642. for n = 0, 3 do
  643. if cornersAbove[n] > 0 then
  644. adjacentCornersAbove = adjacentCornersAbove + 1
  645. end
  646. end
  647. --determine what type of wedge to make
  648. local material = "Water"
  649. local wedge = nil
  650. local rotation = nil
  651. if defaultmaterial then
  652. material = defaultmaterial
  653. else
  654. material, wedge, rotation = c:GetCell(x, y, z) --start with the existing material, wedge, and rotation
  655. end
  656. wedge = 0 --default wedge is a block
  657. rotation = 0 --default rotation is 0
  658. --type 1: 45 degree ramp //must not have a block on top and must have a block under, and be surrounded by 1 side; or 3 sides and the 2 corners between them
  659. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  660. if adjacentSides == 1 then
  661. for n = 0, 3 do
  662. if sides[n] > 0 then
  663. wedge = 1
  664. rotation = (n + 1) % 4
  665. c:SetCell(x, y, z, "Water", "Solid", "Z")
  666. return true
  667. end
  668. end
  669. elseif adjacentSides == 3 then
  670. for n = 0, 3 do
  671. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and corners[(n + 2) % 4] > 0 and sides[(n + 2) % 4] > 0 then
  672. wedge = 1
  673. rotation = (n + 2) % 4
  674. c:SetCell(x, y, z, "Water","Solid","Z")
  675. return true
  676. end
  677. end
  678. end
  679. end
  680. --type 2: 45 degree corner //must not have a block on top and must have a block under, and be surrounded by 2 sides and the 1 corner between them; or 3 sides and 1 corner between 2 of them (facing towards that corner)
  681. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  682. for n = 0, 3 do
  683. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and (adjacentSides == 2 or (adjacentSides == 3 and (corners[(n + 3) % 4] > 0 or (sides[(n + 2) % 4] > 0 and corners[(n + 2) % 4] > 0) or (sides[(n + 3) % 4] > 0 and corners[n] > 0)))) then
  684. wedge = 2
  685. rotation = (n + 2) % 4
  686. c:SetCell(x, y, z, "Water","Solid","Z")
  687. return true
  688. end
  689. end
  690. end
  691. --type 3: 45 degree inverse corner //surrounded by three sides or 4 sides and 3 corners, with nothing above or else a block on top surrounded on 2 sides and the corner between them
  692. if adjacentSides == 3 and surroundings[x][y + 1][z] > 0 then
  693. if adjacentCorners > 1 then
  694. for n = 0, 3 do
  695. if (corners[n] == 0 or cornersAbove[n] == 0) and (sides[(n - 1) % 4] == 0 or sides[n] == 0) and (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0) then
  696. wedge = 3
  697. rotation = (n + 3) % 4
  698. c:SetCell(x, y, z, "Water","Solid","Z")
  699. return true
  700. end
  701. end
  702. end
  703. elseif adjacentSides == 4 and adjacentCorners == 3 then
  704. for n = 0, 3 do
  705. if corners[n] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and cornersAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0)) then
  706. wedge = 3
  707. rotation = (n + 3) % 4
  708. c:SetCell(x, y, z, "Water","Solid","Z")
  709. return true
  710. end
  711. end
  712. end
  713. --type 4: half a cube, as if it were cut diagonally from front to back //surrounded by 2 sides
  714. if adjacentSides == 2 and adjacentCorners < 4 then
  715. for n = 0, 3 do
  716. if sides[n] == 0 and sides[(n + 1) % 4] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] == 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] > 0)) then
  717. wedge = 4
  718. rotation = n
  719. c:SetCell(x, y, z, "Water","Solid","Z")
  720. return true
  721. end
  722. end
  723. end
  724. c:SetCell(x, y, z, "Water","Solid","Z")
  725. wait(1)
  726. c:SetCell(x, y, z, 0,0,0)
  727. return false
  728. end
  729.  
  730. function updateMouseRadius(mouse) -- Makes sure that while the player is digging he doesn't go move his mouse somewhere else going outside our magnitude
  731. p = game.Players.LocalPlayer
  732. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then -- YOU RULE BREAKER!!!
  733. onDeselect() -- Acts as if they stopped holding the mouse down
  734. end
  735. end
  736.  
  737.  
  738.  
  739. function onClick(mouse)
  740. h = game.Players.LocalPlayer.Character.Humanoid
  741. if not enabled or down or h == nil then
  742. return
  743. end
  744. p = game.Players.LocalPlayer
  745. if (p == nil) then return end
  746. if (p.Character == nil) then return end
  747. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then return end
  748. down = true
  749. enabled = false
  750. c = game.Workspace.Terrain
  751. while down do
  752. Tool.Dirt.Smoke.Enabled = true
  753. if not p.PlayerGui:findFirstChild("LoadBar") then
  754. local l = gui:clone()
  755. l.Parent = p.PlayerGui
  756. script.Parent.guiObject.Value = l
  757. end
  758. local guivalue = p.PlayerGui:findFirstChild("LoadBar").Frame.LoadBarPercentage
  759. updateMouseRadius(mouse) -- Checks radius
  760. guivalue.Value = guivalue.Value + 30
  761. if guivalue.Value >= 100 then
  762. local cellPos = c:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
  763. local x = cellPos.x
  764. local y = cellPos.y
  765. local z = cellPos.z
  766. c:SetCell(x, y, z, "Water","Solid",0)
  767. for i = x - 1, x + 1 do
  768. for j = y - 1, y + 1 do
  769. for k = z - 1, z + 1 do
  770. MakeWedge(i, j, k)
  771. end
  772. end
  773. end
  774. Tool.Dirt.Smoke.Enabled = false
  775. onDeselect(mouse) -- Kills GUI
  776. enabled = false
  777. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  778. wait(0.5)
  779. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  780. enabled = true
  781. end
  782. wait()
  783. end
  784. end
  785.  
  786. function onClickOff(mouse)
  787. Tool.Dirt.Smoke.Enabled = false
  788. enabled = true
  789. down = false
  790. if script.Parent.guiObject.Value ~= nil then
  791. script.Parent.guiObject.Value:remove()
  792. end
  793. if Tool.DiggyDiggyHole.Value ~= nil then
  794. Tool.DiggyDiggyHole.Value:Stop()
  795. Tool.DiggyDiggyHole.Value:remove()
  796. end
  797. Tool.GripForward = Vector3.new(0,0,-1)
  798. Tool.GripRight = Vector3.new(0,0,0)
  799. Tool.GripUp = Vector3.new(0, 1, 0)
  800. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  801. Tool.Animate.Disabled = false
  802. end
  803.  
  804. function onDeselect(mouse)
  805. Tool.Dirt.Smoke.Enabled = false
  806. enabled = true
  807. down = false
  808. if script.Parent.guiObject.Value ~= nil then
  809. script.Parent.guiObject.Value:remove()
  810. end
  811. if Tool.DiggyDiggyHole.Value ~= nil then
  812. Tool.DiggyDiggyHole.Value:Stop()
  813. Tool.DiggyDiggyHole.Value:remove()
  814. end
  815. Tool.GripForward = Vector3.new(0,0,-1)
  816. Tool.GripRight = Vector3.new(0,0,0)
  817. Tool.GripUp = Vector3.new(0, 1, 0)
  818. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  819. Tool.Animate.Disabled = false
  820. end
  821.  
  822. function onSelect(mouse)
  823. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  824. mouse.Button1Down:connect(function () onClick(mouse) end)
  825. mouse.Button1Up:connect(function () onClickOff(mouse) end)
  826. end
  827.  
  828.  
  829.  
  830. script.Parent.Equipped:connect(onSelect)
  831. script.Parent.UnEquipped:connect(onDeselect)
  832. end))
  833. ScreenGui30.Name = "LoadBar"
  834. ScreenGui30.Parent = LocalScript29
  835. Frame31.Parent = ScreenGui30
  836. Frame31.Size = UDim2.new(0.375, 0, 0.125, 0)
  837. Frame31.Style = Enum.FrameStyle.RobloxRound
  838. Frame31.Position = UDim2.new(0.625, 0, 0.75, 0)
  839. Frame31.Visible = false
  840. Frame32.Name = "LoadBar"
  841. Frame32.Parent = Frame31
  842. Frame32.Size = UDim2.new(0, 0, 1, 0)
  843. Frame32.Style = Enum.FrameStyle.ChatGreen
  844. TextLabel33.Parent = Frame32
  845. TextLabel33.Text = ""
  846. TextLabel33.Position = UDim2.new(0.5, 0, 0.5, 0)
  847. TextLabel33.Font = Enum.Font.ArialBold
  848. TextLabel33.FontSize = Enum.FontSize.Size24
  849. TextLabel33.TextColor3 = Color3.new(0.6, 0.2, 0)
  850. NumberValue34.Name = "LoadBarPercentage"
  851. NumberValue34.Parent = Frame31
  852. Script35.Parent = NumberValue34
  853. Script35.Disabled = true
  854. table.insert(cors,sandbox(Script35,function()
  855. function UpdateBar()
  856. script.Parent.Parent.LoadBar.Size = UDim2.new((script.Parent.Parent.LoadBarPercentage.Value*.01),0,1,0)
  857. script.Parent.Parent.LoadBar.TextLabel.Text = script.Parent.Parent.LoadBarPercentage.Value.."%"
  858. end
  859.  
  860. script.Parent.Changed:connect(UpdateBar)
  861. end))
  862. Script36.Name = "Debug"
  863. Script36.Parent = Script35
  864. table.insert(cors,sandbox(Script36,function()
  865. -- Online mode is really screwed up :P
  866. wait(1)
  867. script.Parent.Disabled = false
  868. script:remove()
  869. end))
  870. Script37.Name = "Debug"
  871. Script37.Parent = LocalScript29
  872. table.insert(cors,sandbox(Script37,function()
  873. -- Online mode is really screwed up :P
  874. wait(1)
  875. script.Parent.Disabled = false
  876. script:remove()
  877. end))
  878. Tool38.Name = "Water"
  879. Tool38.Parent = mas
  880. Part39.Name = "Shaft"
  881. Part39.Parent = Tool38
  882. Part39.BrickColor = BrickColor.new("Brown")
  883. Part39.Transparency = 1
  884. Part39.Rotation = Vector3.new(90, 0, 180)
  885. Part39.CanCollide = false
  886. Part39.Size = Vector3.new(1, 1.20000005, 1)
  887. Part39.CFrame = CFrame.new(-0.190005645, 3.27113247, -51.3199539, -1, -8.85535792e-06, 2.26414431e-06, -2.26411794e-06, -8.40712164e-06, -1, 8.85556892e-06, -1, 8.40729354e-06)
  888. Part39.BackSurface = Enum.SurfaceType.Weld
  889. Part39.BottomSurface = Enum.SurfaceType.Weld
  890. Part39.FrontSurface = Enum.SurfaceType.Weld
  891. Part39.LeftSurface = Enum.SurfaceType.Weld
  892. Part39.RightSurface = Enum.SurfaceType.Weld
  893. Part39.TopSurface = Enum.SurfaceType.Weld
  894. Part39.Color = Color3.new(0.486275, 0.360784, 0.27451)
  895. Part39.Position = Vector3.new(-0.190005645, 3.27113247, -51.3199539)
  896. Part39.Orientation = Vector3.new(90, -180, 0)
  897. Part39.Color = Color3.new(0.486275, 0.360784, 0.27451)
  898. Part40.Name = "Dirt"
  899. Part40.Parent = Tool38
  900. Part40.BrickColor = BrickColor.new("Dark stone grey")
  901. Part40.Transparency = 1
  902. Part40.Rotation = Vector3.new(0, -0.0199999996, 180)
  903. Part40.CanCollide = false
  904. Part40.Size = Vector3.new(1, 1.20000005, 1)
  905. Part40.CFrame = CFrame.new(-0.190016598, 6.17117882, -51.3199501, -0.99999994, -2.10918824e-06, -0.000354161253, 2.11217753e-06, -1, -8.70998429e-06, -0.000354160846, -8.71034808e-06, 0.99999994)
  906. Part40.BackSurface = Enum.SurfaceType.Weld
  907. Part40.BottomSurface = Enum.SurfaceType.Weld
  908. Part40.FrontSurface = Enum.SurfaceType.Weld
  909. Part40.LeftSurface = Enum.SurfaceType.Weld
  910. Part40.RightSurface = Enum.SurfaceType.Weld
  911. Part40.TopSurface = Enum.SurfaceType.Weld
  912. Part40.Color = Color3.new(0.388235, 0.372549, 0.384314)
  913. Part40.Position = Vector3.new(-0.190016598, 6.17117882, -51.3199501)
  914. Part40.Orientation = Vector3.new(0, -0.0199999996, 180)
  915. Part40.Color = Color3.new(0.388235, 0.372549, 0.384314)
  916. CylinderMesh41.Parent = Part40
  917. CylinderMesh41.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  918. CylinderMesh41.Scale = Vector3.new(0.400000006, 0.400000006, 0.400000006)
  919. Smoke42.Parent = Part40
  920. Smoke42.Size = 0.10000000149012
  921. Smoke42.Color = Color3.new(0.372549, 0.211765, 0.121569)
  922. Smoke42.Enabled = false
  923. Smoke42.Opacity = 0.25
  924. Smoke42.RiseVelocity = -0.5
  925. Smoke42.Color = Color3.new(0.372549, 0.211765, 0.121569)
  926. Part43.Name = "Handle"
  927. Part43.Parent = Tool38
  928. Part43.BrickColor = BrickColor.new("Bright green")
  929. Part43.Transparency = 1
  930. Part43.Rotation = Vector3.new(0, 90, 0)
  931. Part43.Size = Vector3.new(1, 1.20000005, 1)
  932. Part43.CFrame = CFrame.new(-0.190010995, 4.37113523, -51.3199654, -8.85545342e-06, -2.26416819e-06, 1, -8.40721714e-06, 1, 2.26409406e-06, -1, -8.40719804e-06, -8.85547342e-06)
  933. Part43.Color = Color3.new(0.294118, 0.592157, 0.294118)
  934. Part43.Position = Vector3.new(-0.190010995, 4.37113523, -51.3199654)
  935. Part43.Orientation = Vector3.new(0, 90, 0)
  936. Part43.Color = Color3.new(0.294118, 0.592157, 0.294118)
  937. Script44.Name = "Weld"
  938. Script44.Parent = Tool38
  939. table.insert(cors,sandbox(Script44,function()
  940. function Weld(x,y)
  941. local W = Instance.new("Weld")
  942. W.Part0 = x
  943. W.Part1 = y
  944. local CJ = CFrame.new(x.Position)
  945. local C0 = x.CFrame:inverse()*CJ
  946. local C1 = y.CFrame:inverse()*CJ
  947. W.C0 = C0
  948. W.C1 = C1
  949. W.Parent = x
  950. end
  951. function Get(A)
  952. if A.className == "Part" then
  953. Weld(script.Parent.Handle, A)
  954. A.Anchored = false
  955. else
  956. local C = A:GetChildren()
  957. for i=1, #C do
  958. Get(C[i])
  959. end
  960. end
  961. end
  962. function Finale()
  963. Get(script.Parent)
  964. end
  965. script.Parent.Equipped:connect(Finale)
  966. script.Parent.Unequipped:connect(Finale)
  967. Finale()
  968.  
  969. end))
  970. ObjectValue45.Name = "DiggyDiggyHole"
  971. ObjectValue45.Parent = Tool38
  972. Animation46.Name = "SlashAnim"
  973. Animation46.Parent = Tool38
  974. Animation46.AnimationId = "http://www.roblox.com/Asset?ID=54673790"
  975. ObjectValue47.Name = "guiObject"
  976. ObjectValue47.Parent = Tool38
  977. LocalScript48.Name = "Dig"
  978. LocalScript48.Parent = Tool38
  979. LocalScript48.Disabled = true
  980. table.insert(cors,sandbox(LocalScript48,function()
  981. wait(1)
  982. enabled = true
  983. Tool = script.Parent
  984. down = false -- Mouse isn't down
  985. gui = script.LoadBar:clone() -- Displays your process in digging
  986.  
  987. -- Cyrion's auto-wedge fcn:
  988. --sets cell x, y, z to default material if parameter is provided, if not sets cell x, y, z to be whatever material it previously was
  989. --returns true if made a wedge, false if the cell remains a block
  990. function MakeWedge(x, y, z, defaultmaterial)
  991. local c = game.Workspace.Terrain
  992. --gather info about all the cells around x, y, z
  993. surroundings = {} --surroundings is a 3 x 3 x 3 array of the material of the cells adjacent to x, y, z
  994. for i = x - 1, x + 1 do
  995. surroundings[i] = {"Water"}
  996. for j = y - 1, y + 1 do
  997. surroundings[i][j] = {}
  998. for k = z - 1, z + 1 do
  999. local material, wedge, rotation = c:GetCell(i, j, k)
  1000. surroundings[i][j][k] = material.Value
  1001. end
  1002. end
  1003. end
  1004. --make some useful arrays and counters
  1005. local sides = {} --sides is an array of the material of the 4 adjacent sides
  1006. sides[0] = surroundings[x - 1][y][z]
  1007. sides[1] = surroundings[x][y][z + 1]
  1008. sides[2] = surroundings[x + 1][y][z]
  1009. sides[3] = surroundings[x][y][z - 1]
  1010. local adjacentSides = 0
  1011. for n = 0, 3 do
  1012. if sides[n] > 0 then
  1013. adjacentSides = adjacentSides + 1
  1014. end
  1015. end
  1016. local sidesAbove = {} --sides is an array of the material of the 4 adjacent sides 1 height above
  1017. sidesAbove[0] = surroundings[x - 1][y + 1][z]
  1018. sidesAbove[1] = surroundings[x][y + 1][z + 1]
  1019. sidesAbove[2] = surroundings[x + 1][y + 1][z]
  1020. sidesAbove[3] = surroundings[x][y + 1][z - 1]
  1021. local adjacentSidesAbove = 0
  1022. for n = 0, 3 do
  1023. if sidesAbove[n] > 0 then
  1024. adjacentSidesAbove = adjacentSidesAbove + 1
  1025. end
  1026. end
  1027. local corners = {} --corners is an array of the material of the 4 adjacent corners
  1028. corners[0] = surroundings[x - 1][y][z - 1]
  1029. corners[1] = surroundings[x - 1][y][z + 1]
  1030. corners[2] = surroundings[x + 1][y][z + 1]
  1031. corners[3] = surroundings[x + 1][y][z - 1]
  1032. local adjacentCorners = 0
  1033. for n = 0, 3 do
  1034. if corners[n] > 0 then
  1035. adjacentCorners = adjacentCorners + 1
  1036. end
  1037. end
  1038. local cornersAbove = {} --corners is an array of the material of the 4 adjacent corners 1 height above
  1039. cornersAbove[0] = surroundings[x - 1][y + 1][z - 1]
  1040. cornersAbove[1] = surroundings[x - 1][y + 1][z + 1]
  1041. cornersAbove[2] = surroundings[x + 1][y + 1][z + 1]
  1042. cornersAbove[3] = surroundings[x + 1][y + 1][z - 1]
  1043. local adjacentCornersAbove = 0
  1044. for n = 0, 3 do
  1045. if cornersAbove[n] > 0 then
  1046. adjacentCornersAbove = adjacentCornersAbove + 1
  1047. end
  1048. end
  1049. --determine what type of wedge to make
  1050. local material = "Water"
  1051. local wedge = nil
  1052. local rotation = nil
  1053. if defaultmaterial then
  1054. material = defaultmaterial
  1055. else
  1056. material, wedge, rotation = c:GetCell(x, y, z) --start with the existing material, wedge, and rotation
  1057. end
  1058. wedge = 0 --default wedge is a block
  1059. rotation = 0 --default rotation is 0
  1060. --type 1: 45 degree ramp //must not have a block on top and must have a block under, and be surrounded by 1 side; or 3 sides and the 2 corners between them
  1061. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  1062. if adjacentSides == 1 then
  1063. for n = 0, 3 do
  1064. if sides[n] > 0 then
  1065. wedge = 1
  1066. rotation = (n + 1) % 4
  1067. c:SetCell(x, y, z, "Water", "Solid", "Z")
  1068. return true
  1069. end
  1070. end
  1071. elseif adjacentSides == 3 then
  1072. for n = 0, 3 do
  1073. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and corners[(n + 2) % 4] > 0 and sides[(n + 2) % 4] > 0 then
  1074. wedge = 1
  1075. rotation = (n + 2) % 4
  1076. c:SetCell(x, y, z, "Water","Solid","Z")
  1077. return true
  1078. end
  1079. end
  1080. end
  1081. end
  1082. --type 2: 45 degree corner //must not have a block on top and must have a block under, and be surrounded by 2 sides and the 1 corner between them; or 3 sides and 1 corner between 2 of them (facing towards that corner)
  1083. if surroundings[x][y + 1][z] == 0 and surroundings[x][y - 1][z] > 0 then
  1084. for n = 0, 3 do
  1085. if sides[n] > 0 and corners[(n + 1) % 4] > 0 and sides[(n + 1) % 4] > 0 and (adjacentSides == 2 or (adjacentSides == 3 and (corners[(n + 3) % 4] > 0 or (sides[(n + 2) % 4] > 0 and corners[(n + 2) % 4] > 0) or (sides[(n + 3) % 4] > 0 and corners[n] > 0)))) then
  1086. wedge = 2
  1087. rotation = (n + 2) % 4
  1088. c:SetCell(x, y, z, "Water","Solid","Z")
  1089. return true
  1090. end
  1091. end
  1092. end
  1093. --type 3: 45 degree inverse corner //surrounded by three sides or 4 sides and 3 corners, with nothing above or else a block on top surrounded on 2 sides and the corner between them
  1094. if adjacentSides == 3 and surroundings[x][y + 1][z] > 0 then
  1095. if adjacentCorners > 1 then
  1096. for n = 0, 3 do
  1097. if (corners[n] == 0 or cornersAbove[n] == 0) and (sides[(n - 1) % 4] == 0 or sides[n] == 0) and (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0) then
  1098. wedge = 3
  1099. rotation = (n + 3) % 4
  1100. c:SetCell(x, y, z, "Water","Solid","Z")
  1101. return true
  1102. end
  1103. end
  1104. end
  1105. elseif adjacentSides == 4 and adjacentCorners == 3 then
  1106. for n = 0, 3 do
  1107. if corners[n] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] > 0 and cornersAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] == 0)) then
  1108. wedge = 3
  1109. rotation = (n + 3) % 4
  1110. c:SetCell(x, y, z, "Water","Solid","Z")
  1111. return true
  1112. end
  1113. end
  1114. end
  1115. --type 4: half a cube, as if it were cut diagonally from front to back //surrounded by 2 sides
  1116. if adjacentSides == 2 and adjacentCorners < 4 then
  1117. for n = 0, 3 do
  1118. if sides[n] == 0 and sides[(n + 1) % 4] == 0 and (surroundings[x][y + 1][z] == 0 or (sidesAbove[n] == 0 and sidesAbove[(n + 1) % 4] == 0 and sidesAbove[(n + 2) % 4] > 0 and sidesAbove[(n + 3) % 4] > 0)) then
  1119. wedge = 4
  1120. rotation = n
  1121. c:SetCell(x, y, z, "Water","Solid","Z")
  1122. return true
  1123. end
  1124. end
  1125. end
  1126. c:SetCell(x, y, z, "Water","Solid","Z")
  1127. return false
  1128. end
  1129.  
  1130. function updateMouseRadius(mouse) -- Makes sure that while the player is digging he doesn't go move his mouse somewhere else going outside our magnitude
  1131. p = game.Players.LocalPlayer
  1132. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then -- YOU RULE BREAKER!!!
  1133. onDeselect() -- Acts as if they stopped holding the mouse down
  1134. end
  1135. end
  1136.  
  1137.  
  1138.  
  1139. function onClick(mouse)
  1140. h = game.Players.LocalPlayer.Character.Humanoid
  1141. if not enabled or down or h == nil then
  1142. return
  1143. end
  1144. p = game.Players.LocalPlayer
  1145. if (p == nil) then return end
  1146. if (p.Character == nil) then return end
  1147. if (mouse.Hit.p - p.Character.Torso.Position).magnitude > 20 then return end
  1148. down = true
  1149. enabled = false
  1150. c = game.Workspace.Terrain
  1151. while down do
  1152. Tool.Dirt.Smoke.Enabled = true
  1153. if not p.PlayerGui:findFirstChild("LoadBar") then
  1154. local l = gui:clone()
  1155. l.Parent = p.PlayerGui
  1156. script.Parent.guiObject.Value = l
  1157. end
  1158. local guivalue = p.PlayerGui:findFirstChild("LoadBar").Frame.LoadBarPercentage
  1159. updateMouseRadius(mouse) -- Checks radius
  1160. guivalue.Value = guivalue.Value + 30
  1161. if guivalue.Value >= 100 then
  1162. local cellPos = c:WorldToCellPreferSolid(Vector3.new(mouse.Hit.x, mouse.Hit.y, mouse.Hit.z))
  1163. local x = cellPos.x
  1164. local y = cellPos.y
  1165. local z = cellPos.z
  1166. c:SetCell(x, y, z, "Water","Solid",0)
  1167. for i = x - 1, x + 1 do
  1168. for j = y - 1, y + 1 do
  1169. for k = z - 1, z + 1 do
  1170. MakeWedge(i, j, k)
  1171. end
  1172. end
  1173. end
  1174. Tool.Dirt.Smoke.Enabled = false
  1175. onDeselect(mouse) -- Kills GUI
  1176. enabled = false
  1177. mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
  1178. wait(0.5)
  1179. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1180. enabled = true
  1181. end
  1182. wait()
  1183. end
  1184. end
  1185.  
  1186. function onClickOff(mouse)
  1187. Tool.Dirt.Smoke.Enabled = false
  1188. enabled = true
  1189. down = false
  1190. if script.Parent.guiObject.Value ~= nil then
  1191. script.Parent.guiObject.Value:remove()
  1192. end
  1193. if Tool.DiggyDiggyHole.Value ~= nil then
  1194. Tool.DiggyDiggyHole.Value:Stop()
  1195. Tool.DiggyDiggyHole.Value:remove()
  1196. end
  1197. Tool.GripForward = Vector3.new(0,0,-1)
  1198. Tool.GripRight = Vector3.new(0,0,0)
  1199. Tool.GripUp = Vector3.new(0, 1, 0)
  1200. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  1201. Tool.Animate.Disabled = false
  1202. end
  1203.  
  1204. function onDeselect(mouse)
  1205. Tool.Dirt.Smoke.Enabled = false
  1206. enabled = true
  1207. down = false
  1208. if script.Parent.guiObject.Value ~= nil then
  1209. script.Parent.guiObject.Value:remove()
  1210. end
  1211. if Tool.DiggyDiggyHole.Value ~= nil then
  1212. Tool.DiggyDiggyHole.Value:Stop()
  1213. Tool.DiggyDiggyHole.Value:remove()
  1214. end
  1215. Tool.GripForward = Vector3.new(0,0,-1)
  1216. Tool.GripRight = Vector3.new(0,0,0)
  1217. Tool.GripUp = Vector3.new(0, 1, 0)
  1218. Tool.Animate.Disabled = true -- The script seems to crash after digging due to the animation becoming nil. Just restart it.
  1219. Tool.Animate.Disabled = false
  1220. end
  1221.  
  1222. function onSelect(mouse)
  1223. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  1224. mouse.Button1Down:connect(function () onClick(mouse) end)
  1225. mouse.Button1Up:connect(function () onClickOff(mouse) end)
  1226. end
  1227.  
  1228.  
  1229.  
  1230. script.Parent.Equipped:connect(onSelect)
  1231. script.Parent.UnEquipped:connect(onDeselect)
  1232. end))
  1233. ScreenGui49.Name = "LoadBar"
  1234. ScreenGui49.Parent = LocalScript48
  1235. Frame50.Parent = ScreenGui49
  1236. Frame50.Size = UDim2.new(0.375, 0, 0.125, 0)
  1237. Frame50.Style = Enum.FrameStyle.RobloxRound
  1238. Frame50.Position = UDim2.new(0.625, 0, 0.75, 0)
  1239. Frame50.Visible = false
  1240. Frame51.Name = "LoadBar"
  1241. Frame51.Parent = Frame50
  1242. Frame51.Size = UDim2.new(0, 0, 1, 0)
  1243. Frame51.Style = Enum.FrameStyle.ChatGreen
  1244. TextLabel52.Parent = Frame51
  1245. TextLabel52.Text = ""
  1246. TextLabel52.Position = UDim2.new(0.5, 0, 0.5, 0)
  1247. TextLabel52.Font = Enum.Font.ArialBold
  1248. TextLabel52.FontSize = Enum.FontSize.Size24
  1249. TextLabel52.TextColor3 = Color3.new(0.6, 0.2, 0)
  1250. NumberValue53.Name = "LoadBarPercentage"
  1251. NumberValue53.Parent = Frame50
  1252. Script54.Parent = NumberValue53
  1253. Script54.Disabled = true
  1254. table.insert(cors,sandbox(Script54,function()
  1255. function UpdateBar()
  1256. script.Parent.Parent.LoadBar.Size = UDim2.new((script.Parent.Parent.LoadBarPercentage.Value*.01),0,1,0)
  1257. script.Parent.Parent.LoadBar.TextLabel.Text = script.Parent.Parent.LoadBarPercentage.Value.."%"
  1258. end
  1259.  
  1260. script.Parent.Changed:connect(UpdateBar)
  1261. end))
  1262. Script55.Name = "Debug"
  1263. Script55.Parent = Script54
  1264. table.insert(cors,sandbox(Script55,function()
  1265. -- Online mode is really screwed up :P
  1266. wait(1)
  1267. script.Parent.Disabled = false
  1268. script:remove()
  1269. end))
  1270. Script56.Name = "Debug"
  1271. Script56.Parent = LocalScript48
  1272. table.insert(cors,sandbox(Script56,function()
  1273. -- Online mode is really screwed up :P
  1274. wait(1)
  1275. script.Parent.Disabled = false
  1276. script:remove()
  1277. end))
  1278. for i,v in pairs(mas:GetChildren()) do
  1279. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  1280. pcall(function() v:MakeJoints() end)
  1281. end
  1282. mas:Destroy()
  1283. for i,v in pairs(cors) do
  1284. spawn(function()
  1285. pcall(v)
  1286. end)
  1287. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement