Advertisement
ThatOneScript

Dark Magic Bending

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