Advertisement
wulfbawg

EnergySword - RBXLUA

Jun 20th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.71 KB | None | 0 0
  1. -- > CREATED BY WULFBUG9 2014
  2. -- > Seriously, I made this. (wulfbug9)
  3. -- > I'm releasing a ton of my other scripts on this pastebin, too. So go check them out.
  4.  
  5. -- > THIS SCRIPT WAS NEVER FINISHED SO IT'S A FAIL :(
  6. function rand(a)return (math.random()-.5)*2*a end
  7. function q(f,arg)return coroutine.resume(coroutine.create(f),unpack(arg or {}))end
  8. function fade(p,s)q(function(part,start)for i=s,1,.05 do part.Transparency = part.Transparency+0.05 wait(1/30)end end,{p,s})end
  9. function appear(p)q(function(part)for i=1,0,-.05 do part.Transparency = part.Transparency-0.05 wait(1/30)end end,{p})end
  10. function Part(Name,Parent,Size,CFrame,Color,Trans,Anch,Can,Mat,Ref)
  11.     local p = Instance.new("Part",Parent)p.Name = Name
  12.     p.FormFactor = "Custom"p.Size = Size
  13.     p.Anchored = Anch p.CFrame = CFrame
  14.     p.BrickColor = BrickColor.new(Color)p.Transparency = Trans
  15.     p.TopSurface = 0 p.CanCollide = Can
  16.     p.BottomSurface = 0 p.Material = Mat
  17.     p.Reflectance = Ref or 0;p:BreakJoints()
  18.     p.Locked = true;return p
  19. end
  20. function WedgePart(Name,Parent,Size,CFrame,Color,Trans,Anch,Can,Mat,Ref)
  21.     local p = Instance.new("WedgePart",Parent)p.Name = Name
  22.     p.FormFactor = "Custom"p.Size = Size
  23.     p.Anchored = Anch p.CFrame = CFrame
  24.     p.BrickColor = BrickColor.new(Color)p.Transparency = Trans
  25.     p.TopSurface = 0 p.CanCollide = Can
  26.     p.BottomSurface = 0 p.Material = Mat
  27.     p.Reflectance = Ref or 0;p:BreakJoints()
  28.     p.Locked = true;return p
  29. end
  30. function Mesh(Parent,Type,Scale,ID,TID)
  31.     local m = Instance.new("SpecialMesh",Parent)m.MeshType = Type
  32.     m.Scale = Scale or Vector3.new(1,1,1)
  33.     if ID then m.MeshId = ID end if TID then m.TextureId = TID end
  34.     return m
  35. end
  36. function Weld(p1,p2,c0,c1)
  37.     local w = Instance.new("Weld",p1)w.Part0 = p1;w.Part1 = p2
  38.     w.C0,w.C1 = c0 or CFrame.new(),c1 or CFrame.new()
  39.     return w
  40. end
  41. function lerp(a,b,c)
  42.     return a+(b-a)*c
  43. end
  44. do
  45.     local function QuaternionFromCFrame(cf)
  46.         local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  47.         local trace = m00 + m11 + m22
  48.         if trace > 0 then
  49.             local s = math.sqrt(1 + trace)
  50.             local recip = 0.5/s
  51.             return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  52.         else
  53.             local i = 0
  54.             if m11 > m00 then
  55.                 i = 1
  56.             end
  57.             if m22 > (i == 0 and m00 or m11) then
  58.                 i = 2
  59.             end
  60.             if i == 0 then
  61.                 local s = math.sqrt(m00-m11-m22+1)
  62.                 local recip = 0.5/s
  63.                 return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  64.             elseif i == 1 then
  65.                 local s = math.sqrt(m11-m22-m00+1)
  66.                 local recip = 0.5/s
  67.                 return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  68.             elseif i == 2 then
  69.                 local s = math.sqrt(m22-m00-m11+1)
  70.                 local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  71.             end
  72.         end
  73.     end
  74.     local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  75.         local xs, ys, zs = x + x, y + y, z + z
  76.         local wx, wy, wz = w*xs, w*ys, w*zs
  77.         local xx = x*xs
  78.         local xy = x*ys
  79.         local xz = x*zs
  80.         local yy = y*ys
  81.         local yz = y*zs
  82.         local zz = z*zs
  83.         return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  84.     end
  85.     local function QuaternionSlerp(a, b, t)
  86.         local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  87.         local startInterp, finishInterp;
  88.         if cosTheta >= 0.0001 then
  89.             if (1 - cosTheta) > 0.0001 then
  90.                 local theta = math.acos(cosTheta)
  91.                 local invSinTheta = 1/math.sin(theta)
  92.                 startInterp = math.sin((1-t)*theta)*invSinTheta
  93.                 finishInterp = math.sin(t*theta)*invSinTheta
  94.             else
  95.                 startInterp = 1-t
  96.                 finishInterp = t
  97.             end
  98.         else
  99.             if (1+cosTheta) > 0.0001 then
  100.                 local theta = math.acos(-cosTheta)
  101.                 local invSinTheta = 1/math.sin(theta)
  102.                 startInterp = math.sin((t-1)*theta)*invSinTheta
  103.                 finishInterp = math.sin(t*theta)*invSinTheta
  104.             else
  105.                 startInterp = t-1
  106.                 finishInterp = t
  107.             end
  108.         end
  109.         return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp
  110.     end  
  111.     function clerp(a,b,t)
  112.         local qa = {QuaternionFromCFrame(a)}
  113.         local qb = {QuaternionFromCFrame(b)}
  114.         local ax, ay, az = a.x, a.y, a.z
  115.         local bx, by, bz = b.x, b.y, b.z
  116.         local _t = 1-t
  117.         return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  118.     end
  119. end
  120. ---------------------------------------------
  121. player = game:service("Players").LocalPlayer
  122. local char
  123. repeat wait() char = player.Character until char
  124. root = char:WaitForChild("HumanoidRootPart")
  125. torso = char:WaitForChild("Torso")
  126. humanoid = char:WaitForChild("Humanoid")
  127. rarm = char:WaitForChild("Right Arm")
  128. mouse = player:GetMouse()
  129. step = game:service("RunService").Stepped
  130. Mode = ""
  131. LastMode = ""
  132. asset = "http://www.roblox.com/asset/?id="
  133. meshes = {["blast"] = 20329976,["ring"] = 3270017,["spike"] = 1033714,["cone"] = 1082802,["crown"] = 20329976,["cloud"] = 1095708,["diamond"] = 9756362}
  134. sounds = {["gun"] = 131070686;}
  135. mcolor = "Lime green"--"Deep orange"--"Dark Royal blue"--"Toothpaste"--"Institutional white"--"Tr. Yellow"--"Magenta"--
  136. Trailing = Instance.new("BoolValue",script)
  137. c0 = {
  138.     ls = CFrame.new(-1,0.5,0),
  139.     rs = CFrame.new(1,0.5,0),
  140.     lh = CFrame.new(-1,-1,0),
  141.     rh = CFrame.new(1,-1,0),
  142.     nk = CFrame.new(0,1,0),
  143.     tw = CFrame.new(0,0,0),
  144. }
  145. c1 = {
  146.     ls = CFrame.new(0.5,0.5,0),
  147.     rs = CFrame.new(-0.5,0.5,0),
  148.     lh = CFrame.new(-.5,1,0),
  149.     rh = CFrame.new(.5,1,0),
  150.     nk = CFrame.new(0,-.5,0),
  151.     tw = CFrame.new(0,0,0),
  152. }
  153. rs = Weld(torso,char:WaitForChild("Right Arm"),c0.rs,c1.rs)
  154. ls = Weld(torso,char:WaitForChild("Left Arm"),c0.ls,c1.ls)
  155. local lastPos
  156. lastSwing = tick()
  157. local top;
  158. ---------------------------------------------
  159. function Trail(par)
  160.     lastPos = par.CFrame.p
  161.     q(function()
  162.         while Trailing.Value do
  163.             wait(1/30)
  164.             local obj = par:Clone()
  165.             obj.Transparency = 0
  166.             obj.Parent = workspace
  167.             obj.Anchored = true
  168.             obj.CanCollide = false
  169.             distance = (lastPos-par.CFrame.p).magnitude
  170.             obj.Size = Vector3.new(0,0,distance)
  171.             obj.CFrame = CFrame.new(lastPos,par.Position)*CFrame.new(0,0,-distance/2)
  172.             lastPos = par.CFrame.p
  173.             q(function(p)wait(0.5)fade(p,0)for i=0,1,0.1 do wait(1/30)if p:FindFirstChild("Mesh") then local m = p:FindFirstChild("Mesh")local s = m.Scale
  174.                 if s.x>0 then
  175.                     m.Scale = s-Vector3.new(.075,0.075,0)
  176.                 end
  177.             end end end,{obj})
  178.         end
  179.     end)
  180. end
  181. function Smoke(origin,color)
  182.     local p = Part("Effect",workspace,Vector3.new(2,2,2),origin*CFrame.new(rand(5),-1,rand(5)),color or "Black",.25,false,false,"SmoothPlastic")
  183.     local m = Mesh(p,"Sphere",Vector3.new(1.25,1.25,1.25))
  184.     local bp = Instance.new("BodyPosition",p)bp.D = 100 bp.P = 100 bp.position = p.Position+Vector3.new(0,7,0)
  185.     q(function(pa,me)
  186.         fade(pa,.25)
  187.         for i=25,100 do
  188.             me.Scale = me.Scale+Vector3.new(0.15,0.1,0.15)
  189.             wait(1/30)
  190.         end
  191.         pa:Destroy()
  192.     end,{p,m})
  193. end
  194. function brickMagic(origin,color,size)
  195.     local p = Part("Effect",workspace,Vector3.new(size,size,size),origin*CFrame.Angles(rand(5),rand(5),rand(5)),color,.2,true,false,"SmoothPlastic")
  196.     local m = Mesh(p,"Brick")
  197.     q(function(pa,me)
  198.         fade(pa,.2)
  199.         for i=20,100 do
  200.             me.Scale = me.Scale-Vector3.new(0.05,0.05,0.05)
  201.             wait(1/30)
  202.         end
  203.         pa:Destroy()
  204.     end,{p,m})
  205. end
  206. function spikeMagic(origin,size,color)
  207.     local p = Part("Effect",workspace,Vector3.new(1,1,1),origin*CFrame.new(0,-size,0),color,1,true,false,"SmoothPlastic")
  208.     local m = Mesh(p,"FileMesh",Vector3.new(size/2,size*2,size/2),asset..meshes["spike"])
  209.     q(function(pa,me)
  210.         appear(pa)
  211.         for i=1,size,.5 do
  212.             wait(1/30)
  213.             pa.CFrame = pa.CFrame*CFrame.new(0,.5,0)
  214.         end
  215.         wait(math.random(2,3))fade(pa,0)
  216.         Delay(3,function()pa:Destroy()end)
  217.     end,{p,m})
  218. end
  219. function placePart(origin,size,color,material)
  220.     local p = Part("Effect",workspace,Vector3.new(size,size,size),origin*CFrame.Angles(rand(5),rand(5),rand(5)),color,0,true,true,material)
  221.     local m = Mesh(p,"Brick")
  222.     q(function(pa,me)
  223.         wait(5)
  224.         fade(pa,0)
  225.         Delay(1.25,function()pa:Destroy()end)
  226.     end,{p,m})
  227. end
  228. function crater(origin,dist)
  229.     local b = workspace.Base
  230.     local bc = b and tostring(b.BrickColor) or "Bright green"
  231.     local m = b and b.Material or "Grass"
  232.     for i=0,360,30 do
  233.         local cf = origin*CFrame.Angles(0,math.rad(i),0)*CFrame.new(0,0,dist)*CFrame.Angles(math.rad(i/30),0,rand(5))
  234.         placePart(cf,math.random(10,12),bc,m)
  235.     end
  236. end
  237. function ringExplode(origin,color,size)
  238.     local p = Part("Effect",workspace,Vector3.new(size,size,1),origin,color,.2,true,false,"SmoothPlastic")
  239.     local m = Mesh(p,"FileMesh",Vector3.new(),asset..meshes["ring"])
  240.     q(function(pa,me)
  241.         fade(pa,.2)
  242.         for i=.2,1,.025 do
  243.             me.Scale = me.Scale-Vector3.new(0.5,0.5,0)
  244.             wait(1/30)
  245.         end
  246.         pa:Destroy()
  247.     end,{p,m})
  248. end
  249. function crownExplode(origin,color,size)
  250.     local p = Part("Effect",workspace,Vector3.new(size,size,size),origin,color,.2,true,false,"SmoothPlastic")
  251.     local m = Mesh(p,"FileMesh",Vector3.new(size/2,size/2,size/2),asset..meshes["crown"])
  252.     q(function(pa,me)
  253.         fade(pa,.2)
  254.         for i=.2,1,.025 do
  255.             me.Scale = me.Scale+Vector3.new(0.75,0.75,0.75)
  256.             wait(1/30)
  257.         end
  258.         pa:Destroy()
  259.     end,{p,m})
  260. end
  261. function glitter(origin,color)
  262.     local p = Part("Effect",workspace,Vector3.new(0.75,0.75,0.75),origin*CFrame.new(rand(5),rand(5),rand(5))*CFrame.Angles(rand(5),rand(5),rand(5)),color,0,true,false,"SmoothPlastic")
  263.     local m = Mesh(p,"Brick",Vector3.new(1,1,1))
  264.     q(function(pa,me)
  265.         fade(pa,0)
  266.         for i=0,1,.05 do
  267.             me.Scale = me.Scale-Vector3.new(0.05,0.05,0.05)
  268.             wait(1/30)
  269.         end
  270.         pa:Destroy()
  271.     end,{p,m})
  272. end
  273. function quickSound(id,v)
  274.     local s = Instance.new("Sound",workspace)
  275.     s.SoundId = id
  276.     s.PlayOnRemove = true
  277.     s.Volume = v or 1
  278.     delay(0.025,function()s:remove()end)
  279. end
  280. function Shoot()
  281.     quickSound(asset..sounds["gun"],.2)
  282.     local start = top.CFrame*CFrame.Angles(math.pi/2,0,0)
  283.     ringExplode(CFrame.new(start.p,start.p-(start.lookVector*-4)),mcolor,5)
  284.     local vel = start.lookVector
  285.     local p = Part("Bullet",workspace,Vector3.new(1,1,5),start,mcolor,0.4,true,false,"SmoothPlastic")
  286.     local m = Mesh(p,"Sphere")
  287.     local num = 0
  288.     local ign = sword:children()
  289.     local connect
  290.     connect = step:connect(function()
  291.         num = num + 1
  292.         local pp = p.Position
  293.         local h,po
  294.         repeat
  295.             local r = Ray.new(pp,vel.unit*math.min(999.5,vel.magnitude/30+20))
  296.             h,po = workspace:FindPartOnRayWithIgnoreList(r,ign)
  297.             if h then
  298.                 if h.CanCollide then
  299.                     break
  300.                 else
  301.                     table.insert(ign,h)
  302.                     h = nil
  303.                 end
  304.             else
  305.                 break
  306.             end
  307.         until false
  308.         p.CFrame = CFrame.new(po,po+vel)
  309.         if h or num > 300 then
  310.             local cf = p.CFrame
  311.             q(function(cfz)
  312.                 for i=1,math.random(1,3)do
  313.                     Smoke(cfz,mcolor)
  314.                 end
  315.                 if h~=nil then
  316.                     local obj = h.CFrame:pointToObjectSpace(po)
  317.                     local siz = h.Size/2
  318.                     local svec = obj/siz
  319.                     svec = Vector3.new(math.floor(math.abs(svec.X)+.01)*svec.X/math.abs(svec.X),
  320.                         math.floor(math.abs(svec.Y))*svec.Y/math.abs(svec.Y) ,
  321.                         math.floor(math.abs(svec.Z))*svec.Z/math.abs(svec.Z))
  322.                     if svec.magnitude ~= 1 then return end
  323.                     local dir = h.CFrame:vectorToWorldSpace(svec)
  324.                     for i=1,math.random(1,3)do
  325.                         spikeMagic(CFrame.new(po,po-dir)*CFrame.new(math.random(-3,3),0,math.random(-3,3))*CFrame.Angles(math.pi/2,0,0),math.random(5,7),mcolor)
  326.                     end
  327.                 end
  328.             end,{cf})
  329.             if h and h.Parent~=char then
  330.                 local hum;
  331.                 for i,v in pairs(h.Parent:children())do if v:IsA("Humanoid")then hum = v end end
  332.                 if hum then hum:TakeDamage(25)end
  333.             end
  334.             p:Destroy()
  335.             connect:disconnect()
  336.         end
  337.     end)
  338. end
  339. function dmgGui(player,dmg)
  340. end
  341. function checkDmgArea(origin,dmg,d)
  342.     for i,v in pairs(workspace:children())do
  343.         if v~=char and v:FindFirstChild("Torso") then
  344.             local h;
  345.             for _,k in pairs(v:children())do if k:IsA("Humanoid") then h = k end end
  346.             local dist = (origin.p - v:FindFirstChild("Torso").CFrame.p).magnitude
  347.             if dist < d and h~=nil then
  348.                 h.Health = h.Health - dmg
  349.             end
  350.         end
  351.     end
  352. end
  353. --------------------------------------------- make the sword
  354. pcall(function()char:FindFirstChild("Sword"):Destroy()end)
  355. sword = Instance.new("Model",char)
  356. sword.Name = "Sword"
  357. handle = Part("Handle",sword,Vector3.new(0,1,0),torso.CFrame,mcolor,.4,false,false,"SmoothPlastic",.1)
  358. Mesh(handle,"Brick",Vector3.new(.75,1,.25))
  359. hweld = Weld(rarm,handle,CFrame.new(0,-1.1,0)*CFrame.Angles(-math.pi/2,math.pi/2,0))
  360. p1 = Part("P1",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  361. p1m = Instance.new("CylinderMesh",p1)
  362. p1m.Scale = Vector3.new(1.5,.3,1.5)
  363. p1w = Weld(handle,p1,CFrame.new(0,-.5,0))
  364. p2 = Part("P2",sword,Vector3.new(0,.5,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  365. p2m = Mesh(p2,"Brick",Vector3.new(.5,1.1,.5))
  366. p2w = Weld(handle,p2,CFrame.new(.05,-.25,0)*CFrame.Angles(0,0,-.1))
  367. p3 = Part("P3",sword,Vector3.new(0,.5,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  368. p3m = Mesh(p3,"Brick",Vector3.new(.5,1,.5))
  369. p3w = Weld(handle,p3,CFrame.new(.0765,.25,0)*CFrame.Angles(0,0,0))
  370. p4 = Part("P4",sword,Vector3.new(0,.5,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  371. p4m = Mesh(p4,"Brick",Vector3.new(.5,1.1,.5))
  372. p4w = Weld(handle,p4,CFrame.new(-.05,-.25,0)*CFrame.Angles(0,0,.1))
  373. p5 = Part("P5",sword,Vector3.new(0,.5,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  374. p5m = Mesh(p5,"Brick",Vector3.new(.5,1,.5))
  375. p5w = Weld(handle,p5,CFrame.new(-.0765,.25,0)*CFrame.Angles(0,0,0))
  376. p6 = Part("P6",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  377. p6m = Instance.new("CylinderMesh",p6)
  378. p6m.Scale = Vector3.new(1.5,.3,1.5)
  379. p6w = Weld(handle,p6,CFrame.new(.25,.5,0))
  380. p7 = Part("P7",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  381. p7m = Instance.new("CylinderMesh",p7)
  382. p7m.Scale = Vector3.new(1.5,.3,1.5)
  383. p7w = Weld(handle,p7,CFrame.new(-.25,.5,0))
  384. p8 = Part("P8",sword,Vector3.new(.5,0,.25),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  385. p8m = Mesh(p8,"Brick",Vector3.new(1,.3,1.185))
  386. p8w = Weld(handle,p8,CFrame.new(0,.5,0))
  387. p9 = Part("P9",sword,Vector3.new(0,0,0),torso.CFrame,mcolor,0.4,false,false,"SmoothPlastic")
  388. p9m = Instance.new("CylinderMesh",p9)
  389. p9m.Scale = Vector3.new(1.3,.3,1.3)
  390. p9w = Weld(handle,p9,CFrame.new(.25,.55,0))
  391. p10 = Part("P10",sword,Vector3.new(0,0,0),torso.CFrame,mcolor,0.4,false,false,"SmoothPlastic")
  392. p10m = Instance.new("CylinderMesh",p10)
  393. p10m.Scale = Vector3.new(1.3,.3,1.3)
  394. p10w = Weld(handle,p10,CFrame.new(-.25,.55,0))
  395. p11 = Part("P11",sword,Vector3.new(.5,0,.25),torso.CFrame,mcolor,0.4,false,false,"SmoothPlastic")
  396. p11m = Mesh(p11,"Brick",Vector3.new(1,.3,1.025))
  397. p11w = Weld(handle,p11,CFrame.new(0,.55,0))
  398. p12 = Part("P12",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  399. p12m = Instance.new("CylinderMesh",p12)
  400. p12m.Scale = Vector3.new(1.5,.3,1.5)
  401. p12w = Weld(handle,p12,CFrame.new(.25,.6,0))
  402. p13 = Part("P13",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  403. p13m = Instance.new("CylinderMesh",p13)
  404. p13m.Scale = Vector3.new(1.5,.3,1.5)
  405. p13w = Weld(handle,p13,CFrame.new(-.25,.6,0))
  406. p14 = Part("P14",sword,Vector3.new(.5,0,.25),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  407. p14m = Mesh(p14,"Brick",Vector3.new(1,.3,1.185))
  408. p14w = Weld(handle,p14,CFrame.new(0,.6,0))
  409. blade = Part("Blade",sword,Vector3.new(.75,4,0),torso.CFrame,mcolor,.4,false,false,"SmoothPlastic",.1)
  410. bladem = Mesh(blade,"Brick",Vector3.new(1,1,.1))
  411. bladew = Weld(handle,blade,CFrame.new(0,2.625,0))
  412. blight = Instance.new("PointLight",blade)
  413. blight.Color = BrickColor.new(mcolor).Color
  414. p15 = WedgePart("P15",sword,Vector3.new(4,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  415. p15m = Mesh(p15,"Wedge",Vector3.new(1,.1,1.25))
  416. p15w = Weld(blade,p15,CFrame.new(-.25,0,-0.02)*CFrame.Angles(-math.pi/2,math.pi/2,0))
  417. p16 = WedgePart("P16",sword,Vector3.new(4,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  418. p16m = Mesh(p16,"Wedge",Vector3.new(1,.1,1.25))
  419. p16w = Weld(blade,p16,CFrame.new(-.25,0,0.02)*CFrame.Angles(math.pi/2,math.pi/2,0))
  420. p17 = WedgePart("P17",sword,Vector3.new(4,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  421. p17m = Mesh(p17,"Wedge",Vector3.new(1,.1,1.25))
  422. p17w = Weld(blade,p17,CFrame.new(.25,0,0.02)*CFrame.Angles(math.pi/2,-math.pi/2,0))
  423. p18 = WedgePart("P18",sword,Vector3.new(4,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  424. p18m = Mesh(p18,"Wedge",Vector3.new(1,.1,1.25))
  425. p18w = Weld(blade,p18,CFrame.new(.25,0,-0.02)*CFrame.Angles(-math.pi/2,-math.pi/2,0))
  426. p19 = Part("P19",sword,Vector3.new(.75,0,0),torso.CFrame,"Grey",1,false,false,"SmoothPlastic")
  427. p19m = Mesh(p19,"Brick",Vector3.new(1,.625,.1))
  428. p19w = Weld(blade,p19,CFrame.new(0,2.2,0))
  429. p20 = WedgePart("P20",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  430. p20m = Mesh(p20,"Wedge",Vector3.new(.1,3.6,1.25))
  431. p20w = Weld(p19,p20,CFrame.new(-.25,.16,0)*CFrame.Angles(0,math.pi/2,0))
  432. p21 = WedgePart("P20",sword,Vector3.new(0,0,0),torso.CFrame,"Grey",0,false,false,"SmoothPlastic")
  433. p21m = Mesh(p21,"Wedge",Vector3.new(.1,3.6,1.25))
  434. p21w = Weld(p19,p21,CFrame.new(.25,.16,0)*CFrame.Angles(0,-math.pi/2,0))
  435. top = Part("Tip",sword,Vector3.new(0,0,0),torso.CFrame,mcolor,1,false,false,"SmoothPlastic")
  436. topm = Mesh(top,"Brick")
  437. topw = Weld(p19,top,CFrame.new(0,1,0))
  438. ohw = hweld.C0
  439. --------------------------------------------- events and main loop
  440. mouse.Button1Down:connect(function()
  441.     if Mode=="" then
  442.         Mode = "Swing1"
  443.         coroutine.wrap(function()
  444.             for i=1,math.random(3,4)do
  445.                 local cf = torso.CFrame*CFrame.new(rand(5),0,rand(5))
  446.                 checkDmgArea(cf,20,5)
  447.                 spikeMagic(cf,math.random(4,6),mcolor)
  448.             end
  449.         end)()
  450.     elseif Mode=="Swing1" then
  451.         Delay(0.2,function()ringExplode(top.CFrame*CFrame.Angles(math.pi/2,0,0),mcolor,1)end)
  452.         Mode = "Swing2"
  453.     elseif Mode=="Swing2" then
  454.         Delay(0.2,function()
  455.             for i=1,math.random(2,4)do
  456.                 Smoke(top.CFrame,mcolor)
  457.                 checkDmgArea(top.CFrame,20,5)
  458.             end
  459.         end)
  460.         Mode = "Swing3"
  461.     elseif Mode=="Swing3" then
  462.         Mode = ""
  463.     elseif Mode=="Shoot" then
  464.         Shoot()
  465.     end
  466.     lastSwing = tick()
  467. end)
  468. mouse.KeyDown:connect(function(key)
  469.     key:lower()
  470.     if key=="l"then
  471.         if Mode~="Shoot" then
  472.             Mode = "Shoot"
  473.         elseif Mode=="Shoot" then
  474.             Mode = ""
  475.         end
  476.     end
  477. end)
  478. Trailing.Changed:connect(function()
  479.     if Trailing.Value then
  480.         Trail(top)
  481.     end
  482. end)
  483. count = 0
  484. angle = 0
  485. counttime = 70
  486. countspeed = 1
  487. speed = .3
  488. step:connect(function() -- main loop
  489.     count = (count%counttime)+countspeed
  490.     angle = math.pi*math.cos((math.pi*2)/counttime*count)
  491.     torVel = Vector3.new(torso.Velocity.x,0,torso.Velocity.z)
  492.     if (tick()-lastSwing) > .8 and Mode:match("Swing") then
  493.         Mode = ""
  494.     end
  495.     if Mode=="" then
  496.         Trailing.Value = false
  497.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(math.pi/4,0,-math.pi/6),.2)
  498.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-math.pi/6,0,0),.2)
  499.         hweld.C0 = clerp(hweld.C0,ohw,.5)
  500.     elseif Mode=="Swing1" then
  501.         Trailing.Value = true
  502.         glitter(top.CFrame,mcolor)
  503.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(math.pi,0,0),.5)
  504.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(math.pi/6,0,math.pi/5),.2)
  505.         hweld.C0 = clerp(hweld.C0,ohw*CFrame.Angles(0,0,-math.pi/2),.5)
  506.     elseif Mode=="Swing2" then
  507.         Trailing.Value = true
  508.         glitter(top.CFrame,mcolor)
  509.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(math.pi/6,0,math.pi/5),.5)
  510.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(math.pi/6,0,math.pi/4),.2)
  511.         hweld.C0 = clerp(hweld.C0,ohw*CFrame.Angles(0,0,-math.pi/8),.5)
  512.     elseif Mode=="Swing3" then
  513.         Trailing.Value = true
  514.         glitter(top.CFrame,mcolor)
  515.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(math.pi/2,0,-math.pi/3),.5)
  516.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(math.pi/2,0,math.pi/8),.5)
  517.         hweld.C0 = clerp(hweld.C0,ohw*CFrame.Angles(0,0,-math.pi/2),.5)
  518.     elseif Mode=="Shoot" then
  519.         Trailing.Value = true
  520.         local mpos = torso.CFrame * rs.c0 -- thx doogle <3
  521.         local cf = CFrame.new(mpos.p,mouse.Hit.p) * CFrame.Angles(math.pi/2,0,0)
  522.         local x,y,z = torso.CFrame:toObjectSpace(cf):toEulerAnglesXYZ()
  523.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(x,y,z),.5)
  524.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-math.pi/6,0,0),.5)
  525.         hweld.C0 = clerp(hweld.C0,ohw*CFrame.Angles(0,0,-math.pi/2),.5)
  526.     elseif Mode=="Summoning" then
  527.         Trailing.Value = false
  528.         rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(math.pi,0,0),.2)
  529.         ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(math.pi,0,0),.2)
  530.         hweld.C0 = clerp(hweld.C0,ohw*CFrame.Angles(0,0,-math.pi/2),.5)
  531.     end
  532.     LastMode = Mode
  533. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement