Advertisement
epicodascripter

Swords

Feb 16th, 2015
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.61 KB | None | 0 0
  1.  
  2. local asin = math.asin
  3. local atan2 = math.atan2
  4. local rad = math.rad
  5. local sin = math.sin
  6. local abs = math.abs
  7. local ceil = math.ceil
  8.  
  9. local function getAngles(cf)
  10.     local sx,sy,sz,m00,m01,m02,m10,m11,m12,m20,m21,m22 = cf:components()
  11.     return atan2(-m12,m22),asin(m02),atan2(-m01,m00)
  12. end
  13. Lerp = {
  14.     Number = function(C1,C2,inc)
  15.         return C1 + (C2 - C1) * inc
  16.     end;
  17.     CFrame = function(a,b,m)
  18.         local c,d={a:components()},{b:components()}
  19.         table.foreach(c,function(a,b)c[a]=c[a]+(d[a]-c[a])*m end)
  20.         return CFrame.new(unpack(c))
  21.     end;
  22. }
  23. local function genWeld(a,b)
  24.     local w = Instance.new("Weld",a)
  25.     w.Part0 = a
  26.     w.Part1 = b
  27.     return w
  28. end
  29. Part = function(x,y,z,color,tr,cc,an,parent)
  30.     local p = Instance.new('Part',parent or Weapon)
  31.     p.formFactor = 'Custom'
  32.     p.Size = Vector3.new(x,y,z)
  33.     p.BrickColor = BrickColor.new(color)
  34.     p.CanCollide = cc
  35.     p.Transparency = tr
  36.     p.Anchored = an
  37.     p.TopSurface,p.BottomSurface = 0,0
  38.     p:BreakJoints()
  39.     return p
  40. end
  41. Weld = function(p0,p1,x,y,z,rx,ry,rz,par)
  42.     local w = Instance.new('Motor',par or p0)
  43.     w.Part0 = p0
  44.     w.Part1 = p1
  45.     w.C1 = CFrame.new(x,y,z)*CFrame.Angles(rx,ry,rz)
  46.     return w
  47. end
  48. Mesh = function(par,num,x,y,z)
  49.     local msh = nil
  50.     if num == 1 then
  51.         msh = Instance.new("CylinderMesh",par)
  52.     elseif num == 2 then
  53.         msh = Instance.new("SpecialMesh",par)
  54.         msh.MeshType = 'Wedge'
  55.     elseif num == 3 then
  56.         msh = Instance.new("BlockMesh",par)
  57.     elseif type(num) == 'string' then
  58.         msh = Instance.new("SpecialMesh",par)
  59.         msh.MeshId = num
  60.     end
  61.     msh.Scale = Vector3.new(x,y,z)
  62.     return msh
  63. end
  64. anglespeed = 1
  65. yeet = 0
  66. dnc=0
  67. count = 0
  68. angle = 0
  69. counttime = 50
  70. countspeed = 1
  71. speed = 1
  72. hats={}
  73. song={}
  74. local plr=game.Players.LocalPlayer
  75. local pchar=plr.Character
  76. local torso=pchar.Torso
  77. local mouse=plr:GetMouse()
  78. local Neck = genWeld(pchar.Torso,pchar.Head)
  79. Neck.C0 = CFrame.new(0,1,0)
  80. Neck.C1 = CFrame.new(0,-0.5,0)
  81. local LeftShoulder = genWeld(pchar.Torso,pchar['Left Arm'])
  82. LeftShoulder.C0 = CFrame.new(-1,0.5,0)
  83. LeftShoulder.C1 = CFrame.new(0.5,0.5,0)
  84. RightShoulder = genWeld(pchar.Torso,pchar['Right Arm'])
  85. RightShoulder.C0 = CFrame.new(1,0.5,0)
  86. RightShoulder.C1 = CFrame.new(-0.5,0.5,0)
  87. local LeftHip = genWeld(pchar.Torso,pchar['Left Leg'])
  88. LeftHip.C0 = CFrame.new(-1,-1,0)
  89. LeftHip.C1 = CFrame.new(-0.5,1,0)
  90. local RightHip = genWeld(pchar.Torso,pchar['Right Leg'])
  91. RightHip.C0 = CFrame.new(1,-1,0)
  92. RightHip.C1 = CFrame.new(0.5,1,0)
  93. local RootJoint = genWeld(pchar.HumanoidRootPart,pchar.Torso)
  94. RootJoint.C0 = CFrame.new(0,0,0) * CFrame.Angles(-math.pi/2,0,math.pi)
  95. RootJoint.C1 = CFrame.new(0,0,0) * CFrame.Angles(-math.pi/2,0,math.pi)
  96. local w1 = Instance.new("Part",pchar)
  97. w1.CanCollide = false
  98. w1.FormFactor="Custom"
  99. w1.Size=Vector3.new(.2,.2,.2)
  100. w1mesh = Instance.new("SpecialMesh",w1)
  101. w1mesh.MeshId="rbxassetid://90821133"
  102. w1mesh.Scale=Vector3.new(2,2,1)
  103. wing1 = Weld(w1,pchar.Torso,-2.75,1,.75,0,0,0,w1)
  104. local w2 = Instance.new("Part",pchar)
  105. w2.CanCollide = false
  106. w2.FormFactor="Custom"
  107. w2.Size=Vector3.new(.2,.2,.2)
  108. w2mesh = Instance.new("SpecialMesh",w2)
  109. w2mesh.MeshId="rbxassetid://90821193"
  110. w2mesh.Scale=Vector3.new(2,2,1)
  111. wing2 = Weld(w2,pchar.Torso,2.75,1,.75,0,0,0,w2)
  112. -- hair
  113. for i,v in pairs(pchar:GetChildren()) do
  114.     if v:IsA("Hat") then
  115.         v:Destroy()
  116.     end
  117. end
  118. hat = Instance.new("Part",pchar)
  119. hat.CanCollide=false
  120. hat.TopSurface="Smooth"
  121. hat.BottomSurface="Smooth"
  122. hat.Size=Vector3.new(1.67, 2.18, 1.9)
  123. hat.BrickColor=BrickColor.new("Bright red")
  124. Weld(hat,pchar.Head,0,-1.2,0,0,0,0,hat)
  125. hatmesh = Instance.new("SpecialMesh",hat)
  126. hatmesh.MeshId="http://www.roblox.com/asset/?id=164382853"
  127. hatmesh.Scale = Vector3.new(1.1, 1.6, 1.1)
  128. local function newLerpTo(weld)
  129.         return {
  130.                 Weld = weld; -- The weld that will lerp
  131.                 To = weld.C0; -- Where it will lerp to; a CFrame
  132.                 Cache = weld.C0; -- Cache of original position; it helps when making anim keyframes
  133.                 Speed = 0.1; -- Speed of lerp. 0.1 or 0.2 is best
  134.         }
  135. end
  136. LerpTo = {
  137.         Neck = newLerpTo(Neck);
  138.         LeftArm = newLerpTo(LeftShoulder);
  139.         RightArm = newLerpTo(RightShoulder);
  140.         LeftLeg = newLerpTo(LeftHip);
  141.         RightLeg = newLerpTo(RightHip);
  142.         RootJoint = newLerpTo(RootJoint);
  143.         Wing1 = newLerpTo(wing1);
  144.         Wing2 = newLerpTo(wing2);
  145. }
  146. local anim = true
  147. local function updateanims()
  148.     if anim==true then
  149.         if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude < 2 then
  150.             anglespeed = 1/3
  151.             LerpTo.Neck.To = LerpTo.Neck.Cache * CFrame.Angles(sin(angle)*0.05,0,0)
  152.             LerpTo.RightArm.To = LerpTo.RightArm.Cache * CFrame.Angles(rad(45),rad(15),rad(15))
  153.             LerpTo.LeftArm.To = LerpTo.LeftArm.Cache * CFrame.Angles(rad(45),rad(-15),rad(-15))
  154.             LerpTo.RightLeg.To = LerpTo.RightLeg.Cache * CFrame.Angles(0,0,abs(sin(angle))*0.1)
  155.             LerpTo.LeftLeg.To = LerpTo.LeftLeg.Cache * CFrame.Angles(0,0,-abs(sin(angle))*0.1)
  156.         end
  157.         if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude > 2 then
  158.             anglespeed = 1.5
  159.             LerpTo.Neck.To = LerpTo.Neck.Cache * CFrame.Angles(0,0,math.sin(angle)*0.05)
  160.             LerpTo.RightArm.To = LerpTo.RightArm.Cache * CFrame.Angles(sin(angle)*.8,0,0)
  161.             LerpTo.LeftArm.To = LerpTo.LeftArm.Cache * CFrame.Angles(-sin(angle)*.8,0,0)
  162.             LerpTo.RightLeg.To = LerpTo.RightLeg.Cache * CFrame.Angles(-sin(angle)*.8,0,0)
  163.             LerpTo.LeftLeg.To = LerpTo.LeftLeg.Cache * CFrame.Angles(sin(angle)*.8,0,0)
  164.         end
  165.     end
  166. end
  167. local attacking = false
  168. mouse.Button1Down:connect(function()
  169.     if attacking == false then
  170.     attacking = true
  171.     anim = false
  172.     LerpTo.Neck.To = LerpTo.Neck.Cache * CFrame.Angles(sin(angle)*0.05,0,0)
  173.     LerpTo.RightArm.To = LerpTo.RightArm.Cache * CFrame.Angles(rad(0),rad(0),0)
  174.     LerpTo.LeftArm.To = LerpTo.LeftArm.Cache * CFrame.Angles(rad(0),0,0)
  175.     LerpTo.RightLeg.To = LerpTo.RightLeg.Cache * CFrame.Angles(0,0,abs(sin(angle))*0.1)
  176.     LerpTo.LeftLeg.To = LerpTo.LeftLeg.Cache * CFrame.Angles(0,0,-abs(sin(angle))*0.1)
  177.     LerpTo.RightArm.To=LerpTo.RightArm.Cache * CFrame.Angles(rad(170),rad(0),rad(0))
  178.     wait(.5)
  179.     LerpTo.RightArm.To = LerpTo.RightArm.Cache * CFrame.Angles(rad(0),rad(0),rad(0))
  180.     LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(170),rad(0),rad(0))
  181.     wait(.5)
  182.     LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(0),rad(0),rad(0))
  183.     wait(.5)
  184.     anim = true
  185.     attacking = false
  186.     end
  187. end)
  188. mouse.KeyDown:connect(function(key)
  189.     if key == "q" and attacking == false then
  190.         attacking = true
  191.         anim = false
  192.         anglespeed = 3
  193.         LerpTo.RightArm.To = LerpTo.RightArm.Cache*CFrame.Angles(rad(170),rad(0),rad(15))
  194.         LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(170),rad(0),rad(-15))
  195.         wait(.25)
  196.         LerpTo.RightArm.To=LerpTo.RightArm.Cache*CFrame.Angles(rad(25),rad(0),rad(-25))*CFrame.new(-.75,-.30,0)
  197.         LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(25),rad(0),rad(25))*CFrame.new(.75,-.30,0)
  198.         wait(.25)
  199.         LerpTo.RightArm.To=LerpTo.RightArm.Cache*CFrame.Angles(rad(25),rad(90),rad(25))*CFrame.new(-.75,-.30,0)
  200.         LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(25),rad(-90),rad(-25))*CFrame.new(.75,-.30,0)
  201.         wait(.25)
  202.         LerpTo.RightArm.To=LerpTo.RightArm.Cache*CFrame.Angles(rad(170),rad(180),rad(-25))*CFrame.new(-.75,-.30,0)
  203.         LerpTo.LeftArm.To=LerpTo.LeftArm.Cache*CFrame.Angles(rad(170),rad(180),rad(25))*CFrame.new(.75,-.30,0)
  204.         wait(.5)
  205.         attacking = false
  206.         anim = true
  207.     end
  208. end)
  209. local sword = Instance.new("Model",pchar)
  210. sword.Name="XXEpicoBladeXX"
  211. handlep1 = Instance.new("Part",sword)
  212. handlep1.CanCollide=false
  213. handlep1.FormFactor="Custom"
  214. handlep1.Size=Vector3.new(0.2,0.2,1.3)
  215. handlep1.TopSurface="Smooth"
  216. handlep1.BottomSurface="Smooth"
  217. handlep1.BrickColor=BrickColor.new("Really black")
  218. Weld(handlep1,pchar['Right Arm'],0,-1,0,0,0,0,handlep1)
  219. bladep1 = Instance.new("Part",sword)
  220. bladep1.CanCollide=false
  221. bladep1.FormFactor="Custom"
  222. bladep1.Size=Vector3.new(0.2,0.5,3.4)
  223. bladep1.TopSurface="Smooth"
  224. bladep1.BottomSurface="Smooth"
  225. bladep1.BrickColor=BrickColor.new("Really black")
  226. Weld(bladep1,handlep1,0,0,-2.2,0,0,0,bladep1)
  227. bladep2=Instance.new("WedgePart",sword)
  228. bladep2.CanCollide=false
  229. bladep2.FormFactor="Custom"
  230. bladep2.Size=Vector3.new(0.2,0.5,0.5)
  231. bladep2.TopSurface="Smooth"
  232. bladep2.BottomSurface="Smooth"
  233. bladep2.BrickColor=BrickColor.new("Really black")
  234. Weld(bladep2,bladep1,0,0,-1.95,0,0,math.pi/1,bladep1)
  235. bladep1.Touched:connect(function(hit)
  236. if hit.Parent:FindFirstChild("Humanoid") and attacking == true then
  237. hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
  238. end
  239. end)
  240. bladep2.Touched:connect(function(hit)
  241. if hit.Parent:FindFirstChild("Humanoid") and attacking == true then
  242. hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
  243. end
  244. end)
  245. handlep2 = Instance.new("Part",sword)
  246. handlep2.CanCollide=false
  247. handlep2.FormFactor="Custom"
  248. handlep2.Size=Vector3.new(0.2,0.2,1.3)
  249. handlep2.TopSurface="Smooth"
  250. handlep2.BottomSurface="Smooth"
  251. handlep2.BrickColor=BrickColor.new("Really black")
  252. Weld(handlep2,pchar['Left Arm'],0,-1,0,0,0,0,handlep2)
  253. bladep3 = Instance.new("Part",sword)
  254. bladep3.CanCollide=false
  255. bladep3.FormFactor="Custom"
  256. bladep3.Size=Vector3.new(0.2,0.5,3.4)
  257. bladep3.TopSurface="Smooth"
  258. bladep3.BottomSurface="Smooth"
  259. bladep3.BrickColor=BrickColor.new("Really black")
  260. Weld(bladep3,handlep2,0,0,-2.2,0,0,0,bladep3)
  261. bladep4=Instance.new("WedgePart",sword)
  262. bladep4.CanCollide=false
  263. bladep4.FormFactor="Custom"
  264. bladep4.Size=Vector3.new(0.2,0.5,0.5)
  265. bladep4.TopSurface="Smooth"
  266. bladep4.BottomSurface="Smooth"
  267. bladep4.BrickColor=BrickColor.new("Really black")
  268. Weld(bladep4,bladep3,0,0,-1.95,0,0,math.pi/1,bladep3)
  269. bladep3.Touched:connect(function(hit)
  270. if hit.Parent:FindFirstChild("Humanoid") and attacking == true then
  271. hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
  272. end
  273. end)
  274. bladep4.Touched:connect(function(hit)
  275. if hit.Parent:FindFirstChild("Humanoid") and attacking == true then
  276. hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
  277. end
  278. end)
  279. Spawn(function()
  280.     while wait()do
  281.         angle = (angle % 100) + anglespeed/10 -- no matter whut it has to be in a loop or its on exticy
  282.     end
  283. end)
  284. meo=0
  285. sdeb=false
  286. game:service'RunService'.RenderStepped:connect(function()
  287.     meo=meo+1
  288.         for _,v in pairs(LerpTo) do
  289.         v.Weld.C0 = Lerp.CFrame(v.Weld.C0,v.To,v.Speed)end
  290.     updateanims()
  291. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement