Advertisement
OofeyDoofy

DFGKDGDT

Feb 19th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. local Player = game.Players.localPlayer
  2. local Character = Player.Character
  3. local Humanoid = Character.Humanoid
  4. local mouse = Player:GetMouse()
  5. local LeftArm = Character["Left Arm"]
  6. local RightArm = Character["Right Arm"]
  7. local LeftLeg = Character["Left Leg"]
  8. local RightLeg = Character["Right Leg"]
  9. local Head = Character.Head
  10. local Torso = Character.Torso
  11. local cam = game.Workspace.CurrentCamera
  12. local RootPart = Character.HumanoidRootPart
  13. local RootJoint = RootPart.RootJoint
  14. local equipped = false
  15. local attack = false
  16. local Anim = 'Idle'
  17. local idle = 0
  18. local attacktype = 1
  19. local Torsovelocity = (RootPart.Velocity * Vector3.new(1, 0, 1)).magnitude
  20. local velocity = RootPart.Velocity.y
  21. local sine = 0
  22. local change = 1
  23. local grabbed = false
  24. local cn = CFrame.new
  25. local mr = math.rad
  26. local angles = CFrame.Angles
  27. local ud = UDim2.new
  28. local c3 = Color3.new
  29.  
  30. local NeckCF = cn(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
  31. Humanoid.Animator:Destroy()
  32. Character.Animate:Destroy()
  33.  
  34. local RootCF = CFrame.fromEulerAnglesXYZ(-1.57, 0, 3.14)
  35. local RHCF = CFrame.fromEulerAnglesXYZ(0, 1.6, 0)
  36. local LHCF = CFrame.fromEulerAnglesXYZ(0, -1.6, 0)
  37.  
  38. RSH, LSH = nil, nil
  39.  
  40. RW = Instance.new("Weld")
  41. LW = Instance.new("Weld")
  42.  
  43. RH = Torso["Right Hip"]
  44. LH = Torso["Left Hip"]
  45.  
  46. RSH = Torso["Right Shoulder"]
  47. LSH = Torso["Left Shoulder"]
  48.  
  49. RSH.Parent = nil
  50. LSH.Parent = nil
  51.  
  52. RW.Name = "RW"
  53. RW.Part0 = Torso
  54. RW.C0 = cn(1.5, 0.5, 0)
  55. RW.C1 = cn(0, 0.5, 0)
  56. RW.Part1 = RightArm
  57. RW.Parent = Torso
  58.  
  59. LW.Name = "LW"
  60. LW.Part0 = Torso
  61. LW.C0 = cn(-1.5, 0.5, 0)
  62. LW.C1 = cn(0, 0.5, 0)
  63. LW.Part1 = LeftArm
  64. LW.Parent = Torso
  65.  
  66. function clerp(a, b, t)
  67. local qa = {
  68. QuaternionFromCFrame(a)
  69. }
  70. local qb = {
  71. QuaternionFromCFrame(b)
  72. }
  73. local ax, ay, az = a.x, a.y, a.z
  74. local bx, by, bz = b.x, b.y, b.z
  75. local _t = 1 - t
  76. return QuaternionToCFrame(_t * ax + t * bx, _t * ay + t * by, _t * az + t * bz, QuaternionSlerp(qa, qb, t))
  77. end
  78.  
  79. function QuaternionFromCFrame(cf)
  80. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  81. local trace = m00 + m11 + m22
  82. if trace > 0 then
  83. local s = math.sqrt(1 + trace)
  84. local recip = 0.5 / s
  85. return (m21 - m12) * recip, (m02 - m20) * recip, (m10 - m01) * recip, s * 0.5
  86. else
  87. local i = 0
  88. if m11 > m00 then
  89. i = 1
  90. end
  91. if m22 > (i == 0 and m00 or m11) then
  92. i = 2
  93. end
  94. if i == 0 then
  95. local s = math.sqrt(m00 - m11 - m22 + 1)
  96. local recip = 0.5 / s
  97. return 0.5 * s, (m10 + m01) * recip, (m20 + m02) * recip, (m21 - m12) * recip
  98. elseif i == 1 then
  99. local s = math.sqrt(m11 - m22 - m00 + 1)
  100. local recip = 0.5 / s
  101. return (m01 + m10) * recip, 0.5 * s, (m21 + m12) * recip, (m02 - m20) * recip
  102. elseif i == 2 then
  103. local s = math.sqrt(m22 - m00 - m11 + 1)
  104. local recip = 0.5 / s
  105. return (m02 + m20) * recip, (m12 + m21) * recip, 0.5 * s, (m10 - m01) * recip
  106. end
  107. end
  108. end
  109.  
  110. function QuaternionToCFrame(px, py, pz, x, y, z, w)
  111. local xs, ys, zs = x + x, y + y, z + z
  112. local wx, wy, wz = w * xs, w * ys, w * zs
  113. local xx = x * xs
  114. local xy = x * ys
  115. local xz = x * zs
  116. local yy = y * ys
  117. local yz = y * zs
  118. local zz = z * zs
  119. 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))
  120. end
  121.  
  122. function QuaternionSlerp(a, b, t)
  123. local cosTheta = a[1] * b[1] + a[2] * b[2] + a[3] * b[3] + a[4] * b[4]
  124. local startInterp, finishInterp;
  125. if cosTheta >= 0.0001 then
  126. if (1 - cosTheta) > 0.0001 then
  127. local theta = math.acos(cosTheta)
  128. local invSinTheta = 1 / math.sin(theta)
  129. startInterp = math.sin((1 - t) * theta) * invSinTheta
  130. finishInterp = math.sin(t * theta) * invSinTheta
  131. else
  132. startInterp = 1 - t
  133. finishInterp = t
  134. end
  135. else
  136. if (1 + cosTheta) > 0.0001 then
  137. local theta = math.acos(-cosTheta)
  138. local invSinTheta = 1 / math.sin(theta)
  139. startInterp = math.sin((t - 1) * theta) * invSinTheta
  140. finishInterp = math.sin(t * theta) * invSinTheta
  141. else
  142. startInterp = t - 1
  143. finishInterp = t
  144. end
  145. end
  146. 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
  147. end
  148.  
  149. function swait(num)
  150. if num == 0 or num == nil then
  151. game:service'RunService'.RenderStepped:wait(0)
  152. else
  153. for i = 0, num do
  154. game:service'RunService'.RenderStepped:wait(0)
  155. end
  156. end
  157. end
  158.  
  159. function rayCast(Position, Direction, Range, Ignore)
  160. return game:service("Workspace"):FindPartOnRay(Ray.new(Position, Direction.unit * (Range or 999.999)), Ignore)
  161. end
  162.  
  163. game:GetService'RunService'.Stepped:connect(function()
  164. Torsovelocity = (RootPart.Velocity * Vector3.new(1, 0, 1)).magnitude
  165. velocity = RootPart.Velocity.y
  166. sine = sine + change
  167. local hit, pos = rayCast(RootPart.Position, (CFrame.new(RootPart.Position, RootPart.Position - Vector3.new(0, 1, 0))).lookVector, 4, Character)
  168. if equipped == true or equipped == false then
  169. if RootPart.Velocity.y > 1 and hit == nil then
  170. Anim = "Jump"
  171. if attack == false then
  172. RootJoint.C0 = clerp(RootJoint.C0, RootCF * cn(0, 0, 0) * angles(math.rad(-5), math.rad(0), math.rad(0)), .1)
  173. Torso.Neck.C0 = clerp(Torso.Neck.C0, NeckCF * angles(math.rad(10), math.rad(0), math.rad(0)), .1)
  174. RW.C0 = clerp(RW.C0, CFrame.new(1.5, 0.5, 0) * angles(math.rad(-40), math.rad(0), math.rad(30)), .1)
  175. LW.C0 = clerp(LW.C0, CFrame.new(-1.5, 0.5, 0) * angles(math.rad(-40), math.rad(0), math.rad(-30)), .1)
  176. RH.C0 = clerp(RH.C0, cn(1, -.9, -.3) * RHCF * angles(math.rad(3), math.rad(0), math.rad(0)), .1)
  177. LH.C0 = clerp(LH.C0, cn(-1, -.7, -.5) * LHCF * angles(math.rad(-3), math.rad(0), math.rad(0)), .1)
  178. end
  179. elseif RootPart.Velocity.y < -1 and hit == nil then
  180. Anim = "Fall"
  181. if attack == false then
  182. RootJoint.C0 = clerp(RootJoint.C0, RootCF * cn(0, 0, 0) * angles(math.rad(10), math.rad(0), math.rad(0)), .1)
  183. Torso.Neck.C0 = clerp(Torso.Neck.C0, NeckCF * angles(math.rad(10), math.rad(0), math.rad(0)), .1)
  184. RW.C0 = clerp(RW.C0, CFrame.new(1.5, 0.5, 0) * angles(math.rad(-20), math.rad(0), math.rad(50)), .1)
  185. LW.C0 = clerp(LW.C0, CFrame.new(-1.5, 0.5, 0) * angles(math.rad(-20), math.rad(0), math.rad(-50)), .1)
  186. RH.C0 = clerp(RH.C0, cn(1, -1, -.3) * RHCF * angles(math.rad(-5), math.rad(0), math.rad(0)), .1)
  187. LH.C0 = clerp(LH.C0, cn(-1, -.8, -.3) * LHCF * angles(math.rad(-5), math.rad(0), math.rad(0)), .1)
  188. end
  189. elseif Torsovelocity < 1 and hit ~= nil then
  190. Anim = "Idle"
  191. if attack == false then
  192. change = 1
  193. RootJoint.C0 = clerp(RootJoint.C0, RootCF * cn(0, 0, -0.1 + 0.1 * math.cos(sine / 25)) * angles(math.rad(0), math.rad(0), math.rad(5)), .1)
  194. Torso.Neck.C0 = clerp(Torso.Neck.C0, NeckCF * angles(math.rad(5 - 2 * math.cos(sine / 25)), math.rad(0), math.rad(-5)), .1)
  195. RW.C0 = clerp(RW.C0, CFrame.new(1.5, 0.5, 0) * angles(math.rad(0), math.rad(0), math.rad(5 + 3 * math.cos(sine / 25))), 0.1)
  196. LW.C0 = clerp(LW.C0, CFrame.new(-1.5, 0.5, 0) * angles(math.rad(0), math.rad(0), math.rad(-5 - 3 * math.cos(sine / 25))), 0.1)
  197. RH.C0 = clerp(RH.C0, cn(1, -.9 - 0.1 * math.cos(sine / 25), 0) * RHCF * angles(math.rad(-2 + 2 * math.cos(sine / 25)), math.rad(-5), math.rad(0 + 2 * math.cos(sine / 25))), .1)
  198. LH.C0 = clerp(LH.C0, cn(-1, -.9 - 0.1 * math.cos(sine / 25), 0) * LHCF * angles(math.rad(-2 + 2 * math.cos(sine / 25)), math.rad(-5), math.rad(0 + 2 * math.cos(sine / 25))), .1)
  199. end
  200. elseif Torsovelocity > 2 and hit ~= nil then
  201. Anim = "Walk"
  202. if attack == false then
  203. RootJoint.C0 = clerp(RootJoint.C0, RootCF * cn(0, 0, -0.05 + .1 * math.cos(sine / 3)) * angles(math.rad(5), math.rad(0) + RootPart.RotVelocity.Y / 30, math.rad(5 * math.cos(sine / 5))), .2)
  204. Torso.Neck.C0 = clerp(Torso.Neck.C0, NeckCF * angles(math.rad(-3), math.rad(0), math.rad(-5 * math.cos(sine / 5)) + RootPart.RotVelocity.Y / 9), .2)
  205. RW.C0 = clerp(RW.C0, CFrame.new(1.5 - -0 * math.cos(sine / 4), 0.5 - -.05 * math.cos(sine / 4), 0) * angles(math.rad(10 + -50 * math.cos(sine / 4)), math.rad(0 - .1 * math.cos(sine / 25)), math.rad(0 * math.cos(sine / 25))), 0.3)
  206. LW.C0 = clerp(LW.C0, CFrame.new(-1.5, 0.5, 0) * angles(math.rad(50 * math.cos(sine / 4)), math.rad(0), math.rad(4 * math.cos(sine / 4))), .2)
  207. RH.C0 = clerp(RH.C0, cn(1, -1 + .1 * math.cos(sine / 3), 0) * RHCF * angles(math.rad(-2), math.rad(0), math.rad(50 * math.cos(sine / 4))), .3)
  208. LH.C0 = clerp(LH.C0, cn(-1, -1 + .1 * math.cos(sine / 3), 0) * LHCF * angles(math.rad(-2), math.rad(0), math.rad(50 * math.cos(sine / 4))), .3)
  209. end
  210. end
  211. end
  212. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement