Advertisement
simhwui

Untitled

Dec 6th, 2015
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.45 KB | None | 0 0
  1. local player = game.Players.LocalPlayer
  2. local char = player.Character
  3.  
  4. -- Body parts
  5. local torso = char.Torso
  6.  
  7. -- Tool declarations
  8. local mouseDown = false
  9. local keysDown = {}
  10.  
  11. -- Earth bending declarations
  12. local raisingEarth = false
  13. local raisingTower = false
  14. local wall = false
  15. local groundAttack = false
  16. local lastTower = nil
  17. local disabled = {}
  18. local frames = {}
  19. local parts = {}
  20. local Taunts = {"Foolish.", "Take that!", "Heh.", "You have no hope.", "Grow up.", "DIE!", "EARTH, SHOOT!", "GOOD LUCK STAYING ALIVE!", "You pitiful being."}
  21. local raisechats = {"Earth, raise!", "Get Ready to DIE!", "Heheh..", "Time to die.","Fool.", "Worthless.","Muhahah.","Good Luck, You'll Need it.","TROLLFAIC"}
  22.  
  23. -- Main
  24. function main(mouse)
  25. while true do wait(1/30)
  26. local look = CFrame.new(torso.Position, torso.Position + mouse.Hit.lookVector)
  27.  
  28. -- Reset parts
  29. parts = {}
  30.  
  31. -- Get parts
  32. for x = -20, 20, 10 do
  33. for y = -20, 20, 10 do
  34. for z = -30, -10, 10 do
  35. local pos = look * Vector3.new(x, y, z)
  36. getPartsInRegion3(
  37. Region3.new(
  38. pos + Vector3.new(1,1,1)*-9,
  39. pos + Vector3.new(1,1,1)* 9
  40. ),
  41. parts
  42. )
  43. end
  44. end
  45. end
  46.  
  47. -- Mouse down
  48. if mouseDown then
  49. -- Create dif and bodies
  50. for _, part in pairs(parts) do
  51. if part.Name == "Earth" and not disabled[part] then
  52. if not frames[part] and part ~= lastTower then
  53. frames[part] = look:toObjectSpace(part.CFrame)
  54.  
  55. part:ClearAllChildren()
  56. part.Anchored = false
  57.  
  58. -- Create bodies
  59. createBody("Position", part)
  60. createBody("Gyro", part)
  61. end
  62. end
  63. end
  64.  
  65. -- Move bodies
  66. for part in pairs(frames) do
  67. local bodyPos = part:FindFirstChild("BodyPosition")
  68. local bodyGyr = part:FindFirstChild("BodyGyro")
  69.  
  70. -- Bodies exist
  71. if bodyPos and bodyGyr then
  72. local dif = look * frames[part]
  73.  
  74. bodyPos.position = dif.p
  75. bodyGyr.cframe = dif
  76. else
  77. frames[part] = nil
  78. end
  79. end
  80. else
  81. for part in pairs(frames) do
  82. if part.Name == "Earth" then
  83. frames[part] = nil
  84.  
  85. part:ClearAllChildren()
  86. end
  87. end
  88. end
  89. end
  90. end
  91.  
  92. -- On key change
  93. function onKeyChange(mouse, key, state)
  94. -- Raise earth
  95. if key == "e" and state and not raisingEarth then
  96. game:GetService("Chat"):Chat(char.Head, raisechats[math.random(1,#raisechats)], Enum.ChatColor.Red)
  97. raisingEarth = true
  98. while keysDown[key] do
  99. local torsoY = torso.Position.y + 3
  100. local pos = planeY(torso.Position, 0.4 - 4/2)
  101. local dir = planeY(mouse.Hit.lookVector).unit
  102. local frame = CFrame.new(pos, pos + dir) * CFrame.new(r(-10, 10), 0, r(-20, -5))
  103.  
  104. -- Create earth part
  105. local part = createEarth(workspace)
  106. part.Anchored = true
  107. part.Size = Vector3.new(4, 4, 4)
  108. disabled[part] = true
  109.  
  110. -- Raise earth
  111. for i = 1, 4 do i = i/4
  112. part.CFrame = frame * CFrame.new(0, (torsoY - frame.y)*i, 0)
  113. wait(1/10000000)
  114. if not part.Anchored then
  115. break
  116. end
  117. end
  118.  
  119. disabled[part] = nil
  120. part.Anchored = false
  121.  
  122. wait(1/100)
  123. end
  124. raisingEarth = false
  125.  
  126.  
  127.  
  128.  
  129.  
  130. elseif key == "c" and state and not raisingEarth then
  131. game:GetService("Chat"):Chat(char.Head, raisechats[math.random(1,#raisechats)], Enum.ChatColor.Red)
  132. raisingEarth = true
  133. while keysDown[key] do
  134. local torsoY = torso.Position.y + 3
  135. local pos = planeY(torso.Position, 0.4 - 4/2)
  136. local dir = planeY(mouse.Hit.lookVector).unit
  137. local frame = CFrame.new(pos, pos + dir) * CFrame.new(r(-10, 10), 0, r(-20, -5))
  138.  
  139. -- Create earth part
  140. local part = createEarth(workspace)
  141. part.Anchored = true
  142. part.Size = Vector3.new(2, 2, 2)
  143. disabled[part] = true
  144.  
  145. -- Raise earth
  146. for i = 1, 4 do i = i/4
  147. part.CFrame = frame * CFrame.new(0, (torsoY - frame.y)*i, 0)
  148. wait(1/10000000)
  149. if not part.Anchored then
  150. break
  151. end
  152. end
  153.  
  154. disabled[part] = nil
  155. part.Anchored = false
  156.  
  157. wait(1/100)
  158. end
  159. raisingEarth = false
  160.  
  161.  
  162.  
  163. -- Push earth
  164. elseif key == "f" and state then
  165. game:GetService("Chat"):Chat(char.Head, Taunts[math.random(1,#Taunts)], Enum.ChatColor.Red)
  166. for _, part in pairs(parts) do
  167. if part.Name == "Earth" and part ~= lastTower then
  168. part:ClearAllChildren()
  169. part.Anchored = false
  170.  
  171. -- Add force
  172. local bodyForce = createBody("Force", part)
  173. bodyForce.force = mouse.Hit.lookVector*1.5e4 * part:GetMass()
  174.  
  175. game.Debris:AddItem(bodyForce, 1/30)
  176.  
  177. -- Disable part
  178. disabled[part] = true
  179. delay(1, function()
  180. disabled[part] = nil
  181. end)
  182. end
  183. end
  184.  
  185. -- Break earth
  186. elseif key == "b" and state then
  187. game:GetService("Chat"):Chat(char.Head, "Earth, BREAK!", Enum.ChatColor.Red)
  188. for part in pairs(frames) do
  189. if part.Size == Vector3.new(4, 4, 4) then
  190. for x = -1, 2, 2 do
  191. for y = -1, 2, 2 do
  192. for z = -1, 1, 2 do
  193. local oPart = createEarth(workspace)
  194. oPart.Size = Vector3.new(2, 2, 2)
  195. oPart.CFrame = part.CFrame * CFrame.new(x*1.1, y*1.1, z*1.1)
  196. end
  197. end
  198. end
  199. part:Destroy()
  200. end
  201.  
  202. end
  203.  
  204. for part in pairs(frames) do
  205. if part.Size == Vector3.new(25, 15, 25) then
  206. for x = -3, 2, 2 do
  207. for y = -3, 2, 2 do
  208. for z = -3, 1, 2 do
  209. local oPart = createEarth(workspace)
  210. oPart.Size = Vector3.new(2, 2, 2)
  211. oPart.CFrame = part.CFrame * CFrame.new(x*1.1, y*1.1, z*1.1)
  212. end
  213. end
  214. end
  215. part:Destroy()
  216. end
  217.  
  218. end
  219.  
  220. for part in pairs(frames) do
  221. if part.Size == Vector3.new(2, 2, 2) then
  222. for x = -0.5, 2, 2 do
  223. for y = -0.5, 2, 2 do
  224. for z = -0.5, 1, 2 do
  225. local oPart = createEarth(workspace)
  226. oPart.Size = Vector3.new(1, 1, 1)
  227. oPart.CFrame = part.CFrame * CFrame.new(x*1.1, y*1.1, z*1.1)
  228. end
  229. end
  230. end
  231. part:Destroy()
  232. end
  233.  
  234. end
  235.  
  236.  
  237.  
  238.  
  239. -- Raise tower
  240. elseif key == "r" and state and not raisingTower then
  241. game:GetService("Chat"):Chat(char.Head, raisechats[math.random(1,#raisechats)], Enum.ChatColor.Red)
  242. raisingTower = true
  243. lastTower = nil
  244. if torso.Position.y - 5/2 < 20.4 then
  245. local part = createEarth(workspace)
  246. part.Anchored = true
  247. disabled[part] = true
  248.  
  249. for i = 0, 20, 4 do
  250. part.Size = Vector3.new(5, i, 5)
  251. part.CFrame = CFrame.new(torso.Position.x, 0.4 + part.Size.y/2, torso.Position.z)
  252. torso.CFrame = (torso.CFrame - torso.CFrame.p) + Vector3.new(torso.Position.x, part.Position.y + part.Size.y/2 + 5/2, torso.Position.z)
  253. wait(1/30)
  254. end
  255.  
  256. lastTower = part
  257.  
  258. disabled[part] = nil
  259. part.Anchored = false
  260. end
  261. raisingTower = false
  262.  
  263.  
  264. -- Raise wall
  265. elseif key == "t" and state and not wall then
  266. game:GetService("Chat"):Chat(char.Head, raisechats[math.random(1,#raisechats)], Enum.ChatColor.Red)
  267. wall = true
  268. lastWall = nil
  269. if torso.Position.y - 5/2 < 20.4 then
  270. local part = createEarth(workspace)
  271. part.Anchored = true
  272. disabled[part] = true
  273.  
  274. for i = 0, 1, 20 do
  275. part.Size = Vector3.new(25, 15, 25)
  276. part.CFrame = CFrame.new(torso.Position.x, 0.4 + part.Size.y/2, torso.Position.z)
  277. torso.CFrame = (torso.CFrame - torso.CFrame.p) + Vector3.new(torso.Position.x, part.Position.y + part.Size.y/2 + 5/2, torso.Position.z)
  278. wait(1/30)
  279. end
  280.  
  281. lastWall = part
  282.  
  283. disabled[part] = nil
  284. part.Anchored = false
  285. end
  286. wall = false
  287.  
  288. -- Ground attack
  289. elseif key == "g" and state and not groundAttack then
  290. game:GetService("Chat"):Chat(char.Head, Taunts[math.random(1,#Taunts)], Enum.ChatColor.Red)
  291. groundAttack = true
  292. delay(1, function()
  293. groundAttack = false
  294. end)
  295.  
  296. local dir = planeY(mouse.Hit.p - torso.Position).unit
  297. local pos = planeY(torso.Position, 0.4 + 1) + dir*5
  298.  
  299. local ground = {}
  300.  
  301. delay(5, function()
  302. for i = 1, 20 do
  303. for _, part in pairs(ground) do
  304. if part.Anchored then
  305. part.CFrame = part.CFrame + Vector3.new(0, -1/7, 0)
  306. end
  307. end
  308. wait(1/30)
  309. end
  310. for _, part in pairs(ground) do
  311. if part.Anchored then
  312. part:Destroy()
  313. end
  314. end
  315. end)
  316.  
  317. for i = 1, 10 do
  318. local hit, pos2 = rayCast(pos, dir*5, {char})
  319.  
  320. local part = createEarth(workspace)
  321. part.Anchored = true
  322. part.Size = Vector3.new(4, 4, 4)
  323. part.CFrame = CFrame.new(pos2, pos2 + dir) * CFrame.Angles(math.rad(-50), 0, 0) + Vector3.new(0, -0, 0)
  324.  
  325. ground[#ground + 1] = part
  326.  
  327. -- Add force
  328. if hit then
  329. local mass = hit:GetMass()
  330.  
  331. -- Hit player
  332. for _, oPlayer in pairs(game.Players:GetPlayers()) do
  333. if oPlayer.Character and oPlayer.Character:FindFirstChild("Torso") and hit:IsDescendantOf(oPlayer.Character) then
  334. hit = oPlayer.Character.Torso
  335. mass = 20
  336. end
  337. end
  338.  
  339. if hit.Name ~= "Torso" then
  340. hit:ClearAllChildren()
  341. end
  342. hit.Anchored = false
  343.  
  344. -- Add force
  345. local bodyForce = createBody("Force", hit)
  346. bodyForce.force = (dir + Vector3.new(0, 0.2, 0)).unit*1e4 * mass
  347.  
  348. game.Debris:AddItem(bodyForce, 1/30)
  349. break
  350. end
  351.  
  352. pos = pos2
  353. wait(1/20)
  354. end
  355. end
  356. end
  357.  
  358. --- CORE CODE BELOW --- CORE CODE BELOW --- CORE CODE BELOW ---
  359. --- CORE CODE BELOW --- CORE CODE BELOW --- CORE CODE BELOW ---
  360. --- CORE CODE BELOW --- CORE CODE BELOW --- CORE CODE BELOW ---
  361.  
  362. -- Clear old tool
  363. player.Backpack:ClearAllChildren()
  364.  
  365. -- Create tool
  366. local tool = Instance.new("HopperBin")
  367. tool.Parent = player.Backpack
  368. tool.Name = "Dark Bending"
  369.  
  370. -- Tool selected
  371. tool.Selected:connect(function(mouse)
  372. mouse.Icon = "rbxasset://textures\\GunCursor.png"
  373.  
  374. -- Mouse events
  375. mouse.Button1Down:connect(function()
  376. mouseDown = true
  377. end)
  378. mouse.Button1Up:connect(function()
  379. mouseDown = false
  380. end)
  381. mouse.KeyDown:connect(function(key)
  382. keysDown[key:lower()] = true
  383. onKeyChange(mouse, key:lower(), true)
  384. end)
  385. mouse.KeyUp:connect(function(key)
  386. keysDown[key:lower()] = false
  387. onKeyChange(mouse, key:lower(), false)
  388. end)
  389.  
  390. -- Call main
  391. main(mouse)
  392. end)
  393.  
  394. --- LIBRARY BELOW --- LIBRARY BELOW --- LIBRARY BELOW ---
  395. --- LIBRARY BELOW --- LIBRARY BELOW --- LIBRARY BELOW ---
  396. --- LIBRARY BELOW --- LIBRARY BELOW --- LIBRARY BELOW ---
  397.  
  398. -- Ray cast
  399. function rayCast(pos, dir, ignore)
  400. return workspace:FindPartOnRayWithIgnoreList(Ray.new(pos, dir), ignore)
  401. end
  402.  
  403. -- Create body
  404. function createBody(type, path)
  405. local body = Instance.new("Body" .. type)
  406. if type == "Gyro" then
  407. body.maxTorque = Vector3.new(math.huge, math.huge, math.huge)
  408. elseif type ~= "Force" then
  409. body.maxForce = Vector3.new(math.huge, math.huge, math.huge)
  410. end
  411. body.Parent = path
  412. return body
  413. end
  414.  
  415. -- Get parts in region 3
  416. function getPartsInRegion3(region, parts)
  417. repeat
  418. local regParts = workspace:FindPartsInRegion3WithIgnoreList(region, parts, 100)
  419. for i, part in pairs(regParts) do
  420. parts[#parts + 1] = part
  421. end
  422. until #regParts < 100
  423. end
  424.  
  425. -- Random
  426. function r(min, max)
  427. return math.random()*(max - min) + min
  428. end
  429.  
  430. -- Plane y
  431. function planeY(v, y)
  432. return Vector3.new(v.x, y or 0, v.z)
  433. end
  434.  
  435. -- Create earth
  436. function createEarth(path)
  437. local part = createPart("Earth", path)
  438. part.BrickColor = BrickColor.new("Really black")
  439. part.Material = "Slate"
  440. m = Instance.new("Fire",part)
  441. m.Heat = 10
  442. part.Parent = path
  443. return part
  444. end
  445.  
  446. -- Create part
  447. function createPart(name, path)
  448. local part = Instance.new("Part")
  449. part.FormFactor = "Symmetric"
  450. part.BottomSurface = "Smooth"
  451. part.TopSurface = "Smooth"
  452. part.Size = Vector3.new(1, 1, 1)
  453. part.Name = name
  454. part.Parent = path
  455. return part
  456. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement