yudhaprawira

water bending

Jun 29th, 2016
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.41 KB | None | 0 0
  1. --Water bending
  2.  
  3.  
  4. local player=game.Players.LocalPlayer
  5. local character=player.Character
  6. local head=character["Head"]
  7. local torso=character["Torso"]
  8. local humanoid=character["Humanoid"]
  9. local arm={left=character["Left Arm"], right=character["Right Arm"]}
  10. local add={
  11. part=function(parent,anchored,cancollide,color,shape,t,size,cframe)
  12. local p=Instance.new("Part")
  13. p.Parent=parent
  14. p.TopSurface="Smooth"
  15. p.BottomSurface="Smooth"
  16. p.FormFactor="Custom"
  17. p.Anchored=anchored
  18. p.CanCollide=cancollide
  19. p.BrickColor=BrickColor.new(color)
  20. p.Shape=shape
  21. p.Transparency=t
  22. p.Size=size
  23. p.CFrame=cframe
  24. return p
  25. end,
  26. weld=function(parent,part1,cframe)
  27. local w=Instance.new("Weld")
  28. w.Parent=parent
  29. w.Part0=parent
  30. w.Part1=part1
  31. w.C1=cframe
  32. return w
  33. end,
  34. mesh=function(ins,parent,scale)
  35. local m=Instance.new(ins)
  36. m.Parent=parent
  37. m.Scale=scale
  38. return m
  39. end,
  40. sound=function(parent,volume,id)
  41. local s=Instance.new("Sound")
  42. s.Parent=parent
  43. s.Volume=volume
  44. s.SoundId=id
  45. return s
  46. end,
  47. model=function(parent,name)
  48. local m=Instance.new("Model")
  49. m.Parent=parent
  50. m.Name=name
  51. return m
  52. end,
  53. bg=function(parent,cframe)
  54. local g=Instance.new("BodyGyro")
  55. g.Parent=parent
  56. g.maxTorque=Vector3.new(math.huge,math.huge,math.huge)
  57. g.cframe=cframe
  58. return g
  59. end,
  60. bav=function(parent,angular)
  61. local av=Instance.new("BodyAngularVelocity")
  62. av.maxTorque=Vector3.new(math.huge,math.huge,math.huge)
  63. av.Parent=parent
  64. av.angularvelocity=angular
  65. return av
  66. end,
  67. bp=function(parent,pos)
  68. local p=Instance.new("BodyPosition")
  69. p.Parent=parent
  70. p.maxForce=Vector3.new(0,math.huge,0)
  71. p.position=pos
  72. return p
  73. end,
  74. bf=function(parent,force)
  75. local f=Instance.new("BodyForce")
  76. f.Parent=parent
  77. f.force=force
  78. return f
  79. end,
  80. humanoid=function(parent,maxhealth)
  81. local h=Instance.new("Humanoid")
  82. h.Parent=parent
  83. h.MaxHealth=maxhealth
  84. return h
  85. end
  86. }
  87. local c=function(f)coroutine.resume(coroutine.create(f))end
  88. local trailDeb=false
  89. local things=add.model(character,"Water Bending")
  90.  
  91. function computePos(pos1,pos2)
  92. local pos3=Vector3.new(pos2.x,pos1.y,pos2.z)
  93. return CFrame.new(pos1,pos3)
  94. end
  95.  
  96. local touchDeb=false
  97. function touch(hit)
  98. local human=hit.Parent:findFirstChild("Humanoid")
  99. local torso=hit.Parent:findFirstChild("Torso")
  100. if human and torso and human~=humanoid then
  101. local damage=math.random(5,10)
  102. c(function()
  103. human:TakeDamage(damage)
  104. human.PlatformStand=true
  105. torso.Velocity=torso.CFrame.lookVector*-150
  106. torso.RotVelocity=Vector3.new(math.random(-25,25),math.random(-25,25),math.random(-25,25))
  107. wait(1)
  108. human.PlatformStand=false
  109. torso.Velocity=Vector3.new(0,0,0)
  110. torso.RotVelocity=Vector3.new(0,0,0)
  111. end)
  112. end
  113. end
  114.  
  115. function trail(pos)
  116. trailDeb=true
  117. old=pos.Position
  118. c(function()
  119. while trailDeb==true do
  120. wait()
  121. new=pos.Position
  122. local magnitude=(old-new).magnitude
  123. local line=add.part(things,true,false,"Bright blue","Block",0,Vector3.new(8,8,8) ,CFrame.new(old,new)*CFrame.Angles(0,0,-magnitude/2))
  124. old=new
  125. c(function()
  126. for i=.2,1,.2 do
  127. wait()
  128. line.Transparency=i
  129. end
  130. line:remove()
  131. end)
  132. line.Touched:connect(touch)
  133. end
  134. end)
  135. end
  136.  
  137. local pathDeb=false
  138. local pathPart=nil
  139. local bPosition=10
  140. function path()
  141. pathDeb=true
  142. pathPart=add.part(things,true,true,"Bright blue","Block",0,Vector3.new(6,1,6),CFrame.new())
  143. local bp=add.bp(torso,torso.Position+Vector3.new(0,bPosition,0))
  144. while pathDeb==true do
  145. wait()
  146. pathPart.CFrame=torso.CFrame*CFrame.new(0,-4,0)
  147. end
  148. end
  149.  
  150. --Armz
  151. local fakeArm={left=add.part(things,false,false,"White","Block",1,Vector3.new(1,1,1),CFrame.new()), right=add.part(things,false,false,"White","Block",1,Vector3.new(1,1,1),CFrame.new())}
  152. local water={left=add.part(things,false,false,"Bright blue","Ball",1,Vector3.new(1,1,1),CFrame.new()), right=add.part(things,false,false,"Bright blue","Ball",1,Vector3.new(1,1,1),CFrame.new())}
  153. --Weldz
  154. local connectArmWeld={left=add.weld(torso,fakeArm.left,CFrame.new(1.5,-.5,0)), right=add.weld(torso,fakeArm.right,CFrame.new(-1.5,-.5,0))}
  155. local armWeld={left=add.weld(fakeArm.left,arm.left,CFrame.new(0,0.5,0)), right=add.weld(fakeArm.right,arm.right,CFrame.new(0,0.5,0))}
  156. local waterWeld={left=add.weld(water.left,arm.left,CFrame.new(0,-2,0)), right=add.weld(water.right,arm.right,CFrame.new(0,-2,0))}
  157.  
  158. local anim={
  159. equip=function()
  160. for i=.2,1,.2 do
  161. wait()
  162. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(45)*i)
  163. armWeld.right.C0=CFrame.Angles(math.rad(135)*i,0,0)
  164. end
  165. end,
  166. watershoot=function(mouse)
  167. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  168. trail(water.left)
  169. trail(water.right)
  170. local waterbull=add.part(things,false,false,"Bright blue","Ball",0,Vector3.new(6,6,6),CFrame.new((torso.CFrame+torso.CFrame.lookVector*5).p,mouse.hit.p))
  171. waterbull.Touched:connect(touch)
  172. waterbull.Velocity=waterbull.CFrame.lookVector*150
  173. trail(waterbull)
  174. local bf=add.bf(waterbull,Vector3.new(0,waterbull:GetMass()*196.2,0))
  175. for i=.2,1,.2 do
  176. wait()
  177. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(45)*i)
  178. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(45)*i)
  179. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  180. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  181. end
  182. wait(.2)
  183. for i=1,0,-.2 do
  184. wait()
  185. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(45)*i)
  186. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(45)*i)
  187. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  188. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  189. end
  190. game.Debris:AddItem(waterbull,5)
  191. trailDeb=false
  192. end,
  193. waterRaise=function(mouse)
  194. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  195. trail(water.left)
  196. trail(water.right)
  197. for i=.2,1,.2 do
  198. wait()
  199. armWeld.left.C0=CFrame.Angles(math.rad(135)*i,0,-math.rad(5)*i)
  200. armWeld.right.C0=CFrame.Angles(math.rad(135)*i,0,math.rad(5)*i)
  201. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  202. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  203. end
  204. wait(.2)
  205. for i=1,0,-.2 do
  206. wait()
  207. armWeld.left.C0=CFrame.Angles(math.rad(135)*i,0,-math.rad(5)*i)
  208. armWeld.right.C0=CFrame.Angles(math.rad(135)*i,0,math.rad(5)*i)
  209. waterWeld.left.C1=CFrame.new(0,-2+(-math.random(10,12)*i),0)
  210. waterWeld.right.C1=CFrame.new(0,-2+(-math.random(10,12)*i),0)
  211. end
  212. trailDeb=false
  213. end,
  214. waterSpin=function()
  215. trail(water.left)
  216. trail(water.right)
  217. local bg=add.bg(torso,torso.CFrame)
  218. for i=.2,1,.2 do
  219. wait()
  220. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(90)*i)
  221. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(90)*i)
  222. waterWeld.left.C1=CFrame.new(0,-2+(-math.random(5,8)*i),0)
  223. waterWeld.right.C1=CFrame.new(0,-2+(-math.random(5,8)*i),0)
  224. end
  225. local bav=add.bav(torso,Vector3.new(0,75,0))
  226. wait(3)
  227. for i=1,0,-.2 do
  228. wait()
  229. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(90)*i)
  230. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(90)*i)
  231. waterWeld.left.C1=CFrame.new(0,-2+(-5*i),0)
  232. waterWeld.right.C1=CFrame.new(0,-2+(-5*i),0)
  233. end
  234. bg:remove()
  235. bav:remove()
  236. trailDeb=false
  237. end,
  238. bend=function(mouse)
  239. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  240. trail(water.left)
  241. trail(water.right)
  242. for i=.2,1,.2 do
  243. wait()
  244. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(90)*i)
  245. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(90)*i)
  246. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  247. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  248. end
  249. wait(.2)
  250. for i=1,0,-.2 do
  251. wait()
  252. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(45)*i)
  253. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(45)*i)
  254. waterWeld.left.C1=CFrame.new(0,-2+(-15*i),0)
  255. waterWeld.right.C1=CFrame.new(0,-2+(-15*i),0)
  256. end
  257. trailDeb=false
  258. end,
  259. watershoot2=function(mouse)
  260. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  261. trail(water.left)
  262. trail(water.right)
  263. for i=1,40 do
  264. local waterbull=add.part(things,false,false,"Bright blue","Ball",0,Vector3.new(8,8,8),torso.CFrame*CFrame.Angles(0,math.rad(9)*i,0))
  265. waterbull.Velocity=waterbull.CFrame.lookVector*100
  266. trail(waterbull)
  267. local bf=add.bf(waterbull,Vector3.new(0,waterbull:GetMass()*196.2,0))
  268. game.Debris:AddItem(waterbull,5)
  269. waterbull.Touched:connect(touch)
  270. end
  271. for i=.2,1,.2 do
  272. wait()
  273. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(90)*i)
  274. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(90)*i)
  275. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  276. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  277. end
  278. wait(.2)
  279. for i=1,0,-.2 do
  280. wait()
  281. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,math.rad(90)*i)
  282. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,-math.rad(90)*i)
  283. waterWeld.left.C1=CFrame.new(0,-2+(-10*i),0)
  284. waterWeld.right.C1=CFrame.new(0,-2+(-10*i),0)
  285. end
  286. trailDeb=false
  287. end,
  288. waterBack=function(mouse)
  289. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  290. trail(water.left)
  291. trail(water.right)
  292. for i=.2,1,.2 do
  293. wait()
  294. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,0)
  295. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,0)
  296. waterWeld.left.C1=CFrame.new(0,-2+(-20*i),0)
  297. waterWeld.right.C1=CFrame.new(0,-2+(-20*i),0)
  298. end
  299. wait(.2)
  300. for i=1,0,-.2 do
  301. wait()
  302. armWeld.left.C0=CFrame.Angles(math.rad(90)*i,0,0)
  303. armWeld.right.C0=CFrame.Angles(math.rad(90)*i,0,0)
  304. waterWeld.left.C1=CFrame.new(0,-2+(-20*i),0)
  305. waterWeld.right.C1=CFrame.new(0,-2+(-20*i),0)
  306. end
  307. trailDeb=false
  308. end,
  309. waterForward=function(mouse)
  310. torso.CFrame=computePos(torso.CFrame.p,mouse.Hit.p)
  311. torso.Anchored=true
  312. for i=.2,1,.2 do
  313. wait()
  314. armWeld.left.C0=CFrame.Angles(math.rad(135)*i,0,-math.rad(5)*i)
  315. armWeld.right.C0=CFrame.Angles(math.rad(135)*i,0,math.rad(5)*i)
  316. end
  317. for i=1,20 do
  318. wait()
  319. local waterblock=add.part(things,false,false,"Bright blue","Block",0,Vector3.new(4,4,4),torso.CFrame*CFrame.new(0,0,0)*CFrame.Angles(math.rad(45),0,0)+torso.CFrame.lookVector*2*i)
  320. trail(waterblock)
  321. game.Debris:AddItem(waterblock,1)
  322. waterblock.Touched:connect(touch)
  323. end
  324. wait(.2)
  325. torso.Anchored=false
  326. for i=1,0,-.2 do
  327. wait()
  328. armWeld.left.C0=CFrame.Angles(math.rad(135)*i,0,-math.rad(5)*i)
  329. armWeld.right.C0=CFrame.Angles(math.rad(135)*i,0,math.rad(5)*i)
  330. end
  331. trailDeb=false
  332. end
  333. }
  334.  
  335. function getTouched()
  336. for i,v in pairs(things:GetChildren()) do
  337. v.Touched:connect(touch)
  338. end
  339. end
  340.  
  341. local deb=false
  342. local buttonDeb=false
  343. local bin=Instance.new("HopperBin")
  344. bin.Parent=player.Backpack
  345. bin.Name="Water Bending"
  346. bin.Selected:connect(function(mouse)
  347. bin:remove()
  348. anim.equip()
  349. mouse.Button1Down:connect(function()
  350. if deb==false then
  351. deb=true
  352. getTouched()
  353. anim.watershoot(mouse)
  354. anim.equip()
  355. deb=false
  356. end
  357. end)
  358. mouse.KeyDown:connect(function(key)
  359. if key=="q" and deb==false then
  360. deb=true
  361. getTouched()
  362. anim.waterRaise(mouse)
  363. anim.equip()
  364. deb=false
  365. end
  366. if key=="e" and deb==false then
  367. deb=true
  368. getTouched()
  369. anim.waterSpin()
  370. anim.equip()
  371. deb=false
  372. end
  373. if key=="r" and deb==false then
  374. deb=true
  375. getTouched()
  376. anim.bend(mouse)
  377. anim.equip()
  378. deb=false
  379. end
  380. if key=="f" and deb==false then
  381. deb=true
  382. getTouched()
  383. anim.watershoot2(mouse)
  384. anim.equip()
  385. deb=false
  386. end
  387. if key=="g" and deb==false then
  388. deb=true
  389. getTouched()
  390. anim.waterBack(mouse)
  391. anim.equip()
  392. deb=false
  393. end
  394. if key=="h" and deb==false then
  395. deb=true
  396. getTouched()
  397. anim.waterForward(mouse)
  398. anim.equip()
  399. deb=false
  400. end
  401. if key=="z" and buttonDeb==false then
  402. buttonDeb=true
  403. getTouched()
  404. path()
  405. end
  406. if key=="z" and buttonDeb==true then
  407. buttonDeb=false
  408. pathPart:remove() torso["BodyPosition"]:remove()
  409. end
  410. end)
  411. end) --mediafire
Add Comment
Please, Sign In to add comment