hunterwhitney85

crystal sword script

Jul 15th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.51 KB | None | 0 0
  1. --MADE BY OneLegend (NOT THE SCRIPT) LOCAL SCRIPT: JUST RUN!
  2.  
  3. c,d=pcall(function()
  4. ply = game.Players.LocalPlayer
  5. char = ply.Character
  6. torso = char.Torso
  7. head = char.Torso
  8. track = false --- for tracking function
  9. char.Humanoid.MaxHealth,char.Humanoid.Health,char.Humanoid.WalkSpeed = 9000,9000,30
  10. dmg = 20
  11.  
  12. Bo = {["T"] = char["Torso"], ["H"] = char.Head}
  13. Bo.Arms = {["R"] = char["Right Arm"], ["L"] = char["Left Arm"]}
  14. Bo.Legs = {["L"] = char["Left Leg"], ["R"] = char["Right Leg"]}
  15. Bo.Shls = {["R"] = torso["Right Shoulder"], ["L"] = torso["Left Shoulder"]}
  16.  
  17.  
  18. rarm = char["Right Arm"]
  19. rw,lw = Instance.new("Weld"),Instance.new("Weld")
  20. normpos = Bo.Shls.R.C0
  21.  
  22. function lock(a) ---- updating this for 2 hands
  23. if a == 1 then
  24.  
  25. ---RIGHT---
  26. rw.Parent = torso
  27. rw.C0,rw.C1 = Bo.Shls.R.C0 ,Bo.Shls.R.C1
  28. rw.Part0,rw.Part1 = Bo.Shls.R.Part0 ,Bo.Shls.R.Part1
  29. Bo.Shls.R.Parent = nil
  30.  
  31. ---LEFT---
  32. lw.Parent = torso
  33. lw.Part0,lw.Part1 = Bo.Shls.L.Part0 ,Bo.Shls.L.Part1
  34. lw.C0,lw.C1 = Bo.Shls.L.C0 ,Bo.Shls.L.C1
  35.  
  36.  
  37. elseif a == 0 then
  38. Bo.Shls.R.Parent = torso
  39. rw.Parent = nil
  40. Bo.Shls.L.Parent = torso
  41. lw.Parent = nil
  42.  
  43. end
  44. end
  45.  
  46. cfn,ang = CFrame.new,CFrame.Angles
  47. v3n = Vector3.new
  48.  
  49. attacks = {
  50. ["slash"] = CFrame.Angles(1,2,3)
  51. }
  52.  
  53.  
  54.  
  55. sword = Instance.new("Model",char)
  56.  
  57. meshids = {["blast"] = 20329976, ["penguin"] = 15853464, ["ring"] = 3270017,
  58. ["spike"] = 1033714,["cone"] = 1082802,["crown"] = 20329976,["crossbow"] = 15886761,
  59. ["cloud"] = 1095708,["mjolnir"] = 1279013,["diamond"] = 9756362, ["hand"] = 37241605,
  60. ["fist"] = 65322375,["skull"] = 36869983,["totem"] = 35624068,["spikeb"] = 9982590,["dragon"] = 58430372}---some meshids
  61.  
  62.  
  63. ------TOOOOOLS------
  64. T = {["P"] = function(x,y,z,color,transparency,cancollide,anchored)
  65. c = Instance.new("Part",sword)
  66. c.TopSurface,c.BottomSurface = 0,0
  67. c.formFactor = "Custom"
  68. c.Size = Vector3.new(x,y,z)
  69. c.BrickColor = BrickColor.new(color)
  70. c.Transparency = transparency
  71. c.CanCollide = cancollide
  72. if anchored ~= nil then c.Anchored = anchored end
  73. return c
  74. end
  75. ,
  76. ["C"] = function(func) coroutine.resume(coroutine.create(func)) end
  77. ,
  78. ["W"] = function(part0,part1,x,y,z,rx,ry,rz)
  79. w = Instance.new("Weld",sword)
  80. w.Part0,w.Part1 = part0,part1
  81. w.C1 = CFrame.new(x,y,z) * CFrame.Angles(rx,ry,rz)
  82. return w
  83. end
  84. ,
  85. ["BG"] = function(parent)
  86. local c = Instance.new("BodyGyro",parent)
  87. c.P = 20e+003
  88. c.cframe = parent.CFrame
  89. c.maxTorque = Vector3.new(c.P,c.P,c.P)
  90. return c
  91. end
  92. ,
  93. ["BP"] = function(parent,position)
  94. local bp = Instance.new("BodyPosition",parent)
  95. bp.maxForce = Vector3.new()*math.huge
  96. bp.position = position
  97. return bp
  98. end
  99. ,
  100. ["F"] = function(parent,size,heat,color,secondcolor)
  101. f = Instance.new("Fire",parent)
  102. f.Size = size
  103. f.Heat = heat
  104. if color ~= nil then f.Color = BrickColor.new(color).Color end
  105. if secondcolor ~= nil then f.SecondaryColor = BrickColor.new(secondcolor).Color end
  106. return f
  107. end
  108. ,
  109. ["Track"] = function(obj,s,t,lt)
  110. coroutine.resume(coroutine.create(function()
  111. while track do
  112. old = obj.Position
  113. wait()
  114. new = obj.Position
  115.  
  116. mag = (old-new).magnitude
  117. dist = (old+new)/2
  118.  
  119. ray = T.P(s,mag+.2,s,obj.Color,t,false,true)
  120. Instance.new("CylinderMesh",ray)
  121. ray.CFrame = CFrame.new(dist,old)*ang(math.pi/2,0,0)
  122. game:GetService("Debris"):AddItem(ray,lt)
  123.  
  124. end
  125. end)) end,
  126. ["D"] = function(hit) if hit.Parent:findFirstChild("Humanoid") then h=hit.Parent.Humanoid h.Health = h.Health -dmg end end
  127. ,
  128. ["FM"] = function(parent,meshid,x,y,z,meshtexture)
  129. if meshid == "cylinder" then
  130. mesh = Instance.new("CylinderMesh",parent)
  131. mesh.Scale = Vector3.new(x,y,z)
  132. return mesh
  133. else
  134. mesh = Instance.new("SpecialMesh",parent)
  135. if meshid ~= "sphere" then
  136. mesh.MeshId = "rbxassetid://"..meshids[meshid]
  137. else mesh.MeshType = 3 end
  138. mesh.Scale = Vector3.new(x,y,z)
  139. if meshtexture ~= nil then
  140. mesh.TextureId = "rbxassetid://"..textureids[meshtexture]
  141. end
  142. return mesh
  143. end
  144. end
  145. }
  146. --------------------------------------------------
  147. ---MATH SHORTENINGS---
  148. M = {["R"] = function(a,b) return math.random(a,b) end,
  149. ["Cos"] = function(a) return math.cos(a) end,
  150. ["Sin"] = function(a) return math.sin(a) end,
  151. ["D"] = function(a) return math.rad(a) end
  152. }
  153. ---------------------------
  154.  
  155. --[[tutorial to using shortenings
  156. T.P(sizex,sizey,sizez,brickcolor,transparency,cancollide,anchored)
  157. T.W(part0,part1,x,y,z,rx,ry,rz)
  158. T.F(parent,size,heat,color,secondarycolor)
  159. T.FM(parent,meshid(see the list),scalex,scaley,scalez,textureid(optional) ) --- most usefull
  160.  
  161. M.R(a,b) creates a randomvalue beetwen a and b
  162. ]]--
  163.  
  164. p = T.P(.7,2,.7,"Bright blue",.5,false,false) --- The handle in 1 line O_O
  165. p.Name = "Handle"
  166. p.Position = torso.Position --p.CFrame = p.CFrame * CFrame.new(torso.X, torso.Y, torso.Z)
  167. T.FM(p,"cylinder",1,1,1) --- cylindermesh
  168. hw = T.W(p,torso,0,0,1,0,0,M.D(-45))
  169. holdpos = cfn(0,-1.5,0)*ang(math.pi/2,0,0)
  170. torsopos = cfn(0,0,1)*ang(0,0,M.D(-45))
  171.  
  172. crystal = T.P(1,1,1,"Bright red",.5,false,false)
  173. T.W(crystal,p,0,1,0,0,0,0)
  174. T.FM(crystal,"diamond",.5,1,.5)
  175.  
  176. p.Touched:connect(function(h)
  177. T.D(h)
  178. end)
  179.  
  180. c=nil
  181. mainweld = nil
  182. radius = 1
  183.  
  184. main = T.P(1,1,1,"White",1,false,false)
  185. mainweld = T.W(main,p,0,-1.5,0,0,0,0)
  186.  
  187.  
  188. ----SHIELD----
  189. sp = T.P(2,4,.5,"Magenta",.5,false,false)
  190. sp2 = T.P(1,4,.5,"Magenta",.5,false,false)
  191. sp3 = T.P(1,4,.5,"Magenta",.5,false,false)
  192. --sp,sp2,sp3.Transparency = 0.5,0.5,0.5
  193. T.W(sp2,sp,-1.4,0,.15,0,M.D(20),0)
  194. T.W(sp3,sp,1.4,0,.15,0,M.D(-20),0)
  195.  
  196. mw = T.W(sp,Bo.Arms.L,-.5,0,0,0,math.pi/2,0,0)
  197. ----------------------------------------
  198.  
  199. for i = 1,360,60 do --- I weld diamonds to part at bottom of handle
  200. c = T.P(1,1,1,"White",.5,false,false)
  201. T.FM(c,"diamond",.5,1.4,.5)
  202.  
  203. T.W(c,main,M.Cos(M.D(i))*radius,0,M.Sin(M.D(i))*radius,0,0,0)
  204. end
  205.  
  206. T.C(function() -- ROTATE
  207. while true do
  208. wait()
  209. mainweld.C1 = mainweld.C1 * ang(0,M.D(10),0)
  210. end
  211. end)
  212.  
  213.  
  214. T.C(function()
  215. while wait(0.1) do
  216. for i = 0,1,0.1 do
  217. p.Transparency = i
  218. wait()
  219. end
  220.  
  221. for i = 1,0,0.1 do
  222. p.Transparency = i
  223. wait()
  224. end
  225.  
  226. end
  227. end) -- Same as coroutine.create
  228.  
  229. p2 = p:Clone()
  230. p2.Parent = sword
  231. p2.Size = Vector3.new(1,6,1)
  232. p2.Touched:connect(function(hit) T.D(hit,5) end)
  233.  
  234. p3 = T.P(1,3,1,"Black",.5,false,false)
  235. T.FM(p3,"spike",1,3,1)
  236. T.W(p3,p2,0,-4,0,math.pi,0,0)
  237. Instance.new("Sparkles",p)
  238. w=Instance.new("Weld",p)
  239. w.Part0 = p
  240. w.Part1 = p2
  241. w.C1 = cfn(0,4,0)
  242. end)
  243. if c == true then
  244. print("Sucsess loading")
  245. else
  246. print(d)
  247. end
  248.  
  249. bg = nil
  250. bp = nil
  251. ---------ANIMATIONS--------------
  252.  
  253.  
  254.  
  255. function BBGui(Text,Adornee,Par)
  256. b=Instance.new("BillboardGui",Par)
  257. b.Adornee = Adornee
  258. f=Instance.new("Frame",b)
  259. f.BackgroundTransparency = 1
  260. t=Instance.new("TextLabel",b)
  261. t.Text = Text
  262. t.TextColor3 = Color3.new(1,0,1)
  263. return b
  264. end
  265.  
  266.  
  267.  
  268.  
  269. anims = {}
  270.  
  271. anims.Twirl = function()
  272. rw.C0 = rw.C0 * ang(-math.pi/2,0,0)
  273. hw.C0 = hw.C0 * ang(math.pi/2,0,0)
  274.  
  275. bg = T.BG(head)
  276. for i = 1,360*5,20 do
  277. bg.cframe = bg.cframe * ang(0,math.rad(20),0) --rw.C0 = rw.C0 * ang(i)
  278. local ball = T.P(2,2,2,"Lime green",.5,false,false)
  279. ball.Position = (p3.CFrame * cfn(0,p3.Size.y/2,0)).p
  280. bv = Instance.new("BodyVelocity",ball)
  281. bv.maxForce = Vector3.new()*math.huge
  282. bv.velocity = cfn(torso.Position,p3.Position).lookVector * 300
  283. delay(.1,function()
  284. local pos = cfn(ball.Position)
  285. T.C(function()
  286. local pa = T.P(1,1,1,"White",0,false,true)
  287. pa.CFrame = pos
  288. msh = T.FM(pa,"sphere",1,1,1)
  289.  
  290. for i = 1,30 do
  291. wait()
  292. pa.Size = v3n(i,i,i)
  293. pa.CFrame = pos
  294. pa.Transparency = i/30
  295. end
  296. pa:Remove()
  297. end)
  298. ball:Remove()
  299. end)
  300. wait()
  301. end
  302. bg:Remove()
  303. rw.C0 = rw.C0 * ang(math.pi/2,0,0)
  304. hw.C0 = hw.C0 * ang(-math.pi/2,0,0)
  305. end
  306.  
  307. anims.Fire = function()
  308. local f=Instance.new("Fire",p3)
  309. dmg = 40
  310. delay(20,function()
  311. f:remove()
  312. dmg = 20
  313. end)
  314. end
  315.  
  316. anims.ShieldUp = function()
  317. for i = 1,50,20 do
  318. wait()
  319. lw.C0 = lw.C0 * ang(0,0,M.D(-20))
  320. end
  321. for i = 1,50,20 do
  322. wait()
  323. lw.C0 = lw.C0 * ang(M.D(20),0,0)
  324. end
  325. end
  326.  
  327. anims.ShieldDown = function()
  328. for i = 1,50,20 do
  329. wait()
  330. lw.C0 = lw.C0 * ang(M.D(-20),0,0)
  331. end
  332. for i = 1,50,20 do
  333. wait()
  334. lw.C0 = lw.C0 * ang(0,0,M.D(20))
  335. end
  336.  
  337. end
  338.  
  339.  
  340. anims.Equip = function()
  341. for i = 1,220,20 do
  342. wait()
  343. rw.C0 = rw.C0 * ang(0,0,M.D(20))
  344. end
  345. hw.Part1,hw.C1 = Bo.Arms.R,holdpos
  346. for i = 1,220-90,20 do
  347. wait()
  348. rw.C0 = rw.C0 * ang(0,0,M.D(-20))
  349. end
  350. rw.C0 = normpos*ang(0,0,math.pi/2)
  351. end
  352.  
  353. anims.UnEquip = function()
  354. for i = 1,180,20 do
  355. wait()
  356. rw.C0 = rw.C0 * ang(0,0,M.D(20))
  357. end
  358. hw.Part1,hw.C1 = torso,torsopos
  359. for i = 1,220,20 do
  360. wait()
  361. rw.C0 = rw.C0 * ang(0,0,M.D(-20))
  362. end
  363. end
  364.  
  365. anims.Equip2 = function()
  366. for i = 1,90,5 do
  367. wait()
  368. rw.C0 = rw.C0 * ang(0,0,M.D(5))
  369. end rw.C0 = normpos * ang(0,0,M.D(90)) end
  370.  
  371. anims.UnEquip2 = function()
  372. for i = 90,0,-20 do
  373. wait()
  374. rw.C0 = rw.C0 * ang(0,0,M.D(-20))
  375. end
  376. end
  377.  
  378. anims.Slash = function()
  379. for i = 1,90,20 do
  380. rw.C0 = rw.C0 * ang(0,M.D(20),0)
  381. wait()
  382. end
  383.  
  384. for i = 90,1,-20 do
  385. rw.C0 = rw.C0 * ang(0,0,M.D(-20))
  386. wait()
  387. end
  388. for i = 90,1,-20 do
  389. rw.C0 = rw.C0 * ang(0,0,M.D(20))
  390. wait()
  391. end
  392.  
  393. for i = 1,90,20 do
  394. rw.C0 = rw.C0 * ang(0,M.D(-20),0)
  395. wait()
  396. end
  397. end
  398.  
  399. anims.Fist = function(mouse)
  400. pa = T.P(1,1,1,"Black",.5,false,false)
  401.  
  402. --[[p=Instance.new("Part",Workspace)
  403. p.Anchored = true --flying fist? ya]]--
  404.  
  405. T.FM(p,"fist",1,1,1)
  406. T.W(p,Bo.Arms.L,0,-2,0,0,0,0)
  407.  
  408. end
  409.  
  410. anims.dragon = function(mouse)
  411. local endpos = mouse.hit.p
  412. for i = 1,90,20 do
  413. lw.C0 = lw.C0 * ang(0,0,M.D(-20))
  414. end
  415.  
  416. for i = 1,50,10 do
  417. lw.C0 = lw.C0 * ang(M.D(-10),0,0)
  418. end
  419.  
  420. local ray = T.P(5,1,5,"Bright red",.5,false,true)
  421. startpos = sp.CFrame * cfn(0,0,-1)
  422. T.FM(ray,"cylinder",1,1,1)
  423.  
  424. ray.CFrame = startpos
  425.  
  426.  
  427.  
  428. mag = (startpos.p-endpos).magnitude
  429.  
  430. local head = T.P(1,1,1,"Bright red",.5,false,true)
  431. T.FM(head,"dragon",4,4,4)
  432.  
  433. for i = 1,mag do
  434. wait()
  435. startpos = sp.CFrame * cfn(0,0,-1)
  436. ray.Size = v3n(5,i,5)
  437. ray.CFrame = (cfn(startpos.p,endpos)*cfn(0,0,-ray.Size.y/2))*ang(math.pi/2,0,0)
  438. head.CFrame = ray.CFrame * cfn(0,-ray.Size.y/2,0) * ang(-math.pi/2,0,0)
  439. end
  440.  
  441. for i = 1,50,10 do
  442. lw.C0 = lw.C0 * ang(M.D(10),0,0)
  443. end
  444.  
  445. for i = 1,90,20 do
  446. lw.C0 = lw.C0 * ang(0,0,M.D(20))
  447. end
  448.  
  449. ray:Remove() head:Remove()
  450. end
  451.  
  452.  
  453. swirling = false
  454. anims.Swirl = function(mouse)
  455. if swirling == false and mouse.Target ~= nil then
  456. swirling = true
  457. eff = function(a)
  458. T.C(function()
  459. wait()
  460. local p = T.P(1,1,1,"Black",.5,false,true)
  461. p.CFrame = a
  462. local msh = T.FM(p,"blast",1,1,1)
  463. for i = 1,30 do
  464. wait()
  465. msh.Scale = Vector3.new(i,i/2,i)
  466. p.Transparency = i/30
  467. end
  468. p:Remove()
  469. end)
  470. end
  471.  
  472. rw.C0 = normpos * ang(0,0,math.pi)
  473. hw.C0 = hw.C0 * ang(math.pi/2,0,0)
  474. bg = T.BG(torso)
  475. local original = bg.cframe
  476. --T.C(function() while swirling do wait() bg.cframe = bg.cframe * ang(0,M.D(100),0) end end)
  477. eff(torso.CFrame *cfn(0,-3,0))
  478. bp = T.BP(torso,torso.Position + v3n(0,70,0))
  479. while (bp.position-torso.Position).magnitude > 3 do wait() end --- waits
  480.  
  481. if mouse.Target ~= nil then
  482. bg.cframe = cfn(torso.Position,mouse.hit.p) * ang(-math.pi/2,0,0)
  483. bp.position = (mouse.hit.p + v3n(0,3,0))
  484.  
  485. eff(bg.cframe * ang(math.pi,0,0))
  486.  
  487. while (bp.position-torso.Position).magnitude > 5 do wait() end --- waits
  488.  
  489. bg.cframe = original bp:Remove()
  490. game:GetService("Debris"):AddItem(bg,.5)
  491.  
  492. rw.C0 = normpos * ang(0,0,math.pi/2)
  493. hw.C0 = hw.C0 * ang(-math.pi/2,0,0)
  494. swirling = false
  495. end
  496.  
  497. else
  498. bp:Remove() bg:Remove() rw.C0 = normpos * ang(0,0,math.pi/2)
  499. hw.C0 = hw.C0 * ang(-math.pi/2,0,0)
  500.  
  501. end
  502. end
  503.  
  504. radi = 5
  505. atk = {"Twirl","Fire","Swirl","Dragon","Slash","Fist","ShieldUp"}
  506.  
  507.  
  508. function createhumanoid(name,part,parent)
  509. mo = Instance.new("Model",parent)
  510. mo.Name = name
  511. part.Name = "Head"
  512. part.Parent = mo
  513. tor = T.P(.1,.1,.1,"White",1,false,false)
  514. tor.Name = "Torso"
  515. tor.Parent = mo
  516. T.W(tor,part,0,0,0,0,0,0)
  517. hum = Instance.new("Humanoid",mo)
  518. hum.Health = 0
  519. hum.MaxHealth = 0
  520. end
  521. ---------------------------------
  522. tab = nil
  523.  
  524. scrbox = nil
  525. current = 1
  526.  
  527. function scroll(direction)
  528. if scrbox ~= nil then
  529. current = current+(direction)
  530.  
  531. if current > #atk then current = 1
  532. elseif current < 1 then current = #atk
  533. end
  534.  
  535. scrbox.Adornee = tab:GetChildren()[current]
  536. end
  537.  
  538. end
  539.  
  540.  
  541. ply.Chatted:connect(function(msg)
  542.  
  543. if msg == "#accept" and mod ~= nil then
  544. anims[atk[current]]()
  545. end
  546.  
  547. end)
  548.  
  549. function showtablets()
  550. if tab == nil then
  551.  
  552. tab = Instance.new("Model",sword)
  553.  
  554. for i,v in pairs(atk) do
  555. tp = T.P(2,1.5,2,"Black",.5,false,false)
  556. tp.Parent = tab
  557. createhumanoid(v,tp,tab)
  558.  
  559. local bp = T.BP(tp,torso.Position)
  560.  
  561. T.C(function()
  562. while true do
  563. wait()
  564. o = 360/#atk*i
  565. bp.position = torso.Position + v3n(M.Cos(M.D(o))*radi,0,M.Sin(M.D(o))*radi)
  566. end
  567. end)
  568.  
  569. end
  570.  
  571. scrbox = Instance.new("SelectionBox",Workspace)
  572. scrbox.Adornee = tab:GetChildren()[current]
  573.  
  574. elseif tab ~= nil then tab:Remove() tab = nil
  575. end
  576. end
  577.  
  578. -------------------------------------
  579.  
  580. hopper = Instance.new("HopperBin",ply.Backpack)
  581. hopper.Name = "Crystal Lance"
  582.  
  583. hopper.Deselected:connect(function()
  584. anims.UnEquip()
  585. lock(0) track = false
  586. end)
  587.  
  588.  
  589. hopper.Selected:connect(function(mouse)
  590. lock(1)
  591. anims.Equip()
  592. track = true
  593. T.Track(p2,.3,.5,1)
  594.  
  595. mouse.KeyUp:connect(function(key)
  596. if key == string.char(48) then anims.ShieldDown()
  597. end end)
  598.  
  599. mouse.KeyDown:connect(function(key)
  600. k=key:lower()
  601. if k == "f" then anims.Slash()
  602. elseif k == "q" then anims.UnEquip2() wait(1) anims.Equip2()
  603. elseif k == "t" then anims.Twirl()
  604. elseif key == "r" then anims.Swirl(mouse)
  605. elseif key == "k" then anims.Fire()
  606. elseif key == string.char(48) then anims.ShieldUp()
  607. elseif key == "j" then anims.Fist(mouse)
  608. elseif key == "g" then anims.dragon(mouse)
  609.  
  610. elseif key == "x" then showtablets()
  611. elseif key == "z" then scroll(-1) elseif key == "c" then scroll(1)
  612. elseif key == "v" then if scrbox ~= nil then anims[scrbox.Adornee.Name](mouse) end
  613.  
  614. end
  615. end)
  616.  
  617. end)
Add Comment
Please, Sign In to add comment