jai1515hb

Untitled

Jan 3rd, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.79 KB | None | 0 0
  1. --This is just a fun script. Make it local to work, have fun. --
  2. do --CFrame lerp
  3. local function QuaternionFromCFrame(cf)
  4. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  5. local trace = m00 + m11 + m22
  6. if trace > 0 then
  7. local s = math.sqrt(1 + trace)
  8. local recip = 0.5/s
  9. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  10. else
  11. local i = 0
  12. if m11 > m00 then
  13. i = 1
  14. end
  15. if m22 > (i == 0 and m00 or m11) then
  16. i = 2
  17. end
  18. if i == 0 then
  19. local s = math.sqrt(m00-m11-m22+1)
  20. local recip = 0.5/s
  21. return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  22. elseif i == 1 then
  23. local s = math.sqrt(m11-m22-m00+1)
  24. local recip = 0.5/s
  25. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  26. elseif i == 2 then
  27. local s = math.sqrt(m22-m00-m11+1)
  28. local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  29. end
  30. end
  31. end
  32. local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  33. local xs, ys, zs = x + x, y + y, z + z
  34. local wx, wy, wz = w*xs, w*ys, w*zs
  35. local xx = x*xs
  36. local xy = x*ys
  37. local xz = x*zs
  38. local yy = y*ys
  39. local yz = y*zs
  40. local zz = z*zs
  41. 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))
  42. end
  43. local function QuaternionSlerp(a, b, t)
  44. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  45. local startInterp, finishInterp;
  46. if cosTheta >= 0.0001 then
  47. if (1 - cosTheta) > 0.0001 then
  48. local theta = math.acos(cosTheta)
  49. local invSinTheta = 1/math.sin(theta)
  50. startInterp = math.sin((1-t)*theta)*invSinTheta
  51. finishInterp = math.sin(t*theta)*invSinTheta
  52. else
  53. startInterp = 1-t
  54. finishInterp = t
  55. end
  56. else
  57. if (1+cosTheta) > 0.0001 then
  58. local theta = math.acos(-cosTheta)
  59. local invSinTheta = 1/math.sin(theta)
  60. startInterp = math.sin((t-1)*theta)*invSinTheta
  61. finishInterp = math.sin(t*theta)*invSinTheta
  62. else
  63. startInterp = t-1
  64. finishInterp = t
  65. end
  66. end
  67. 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
  68. end
  69. function clerp(a,b,t)
  70. local qa = {QuaternionFromCFrame(a)}
  71. local qb = {QuaternionFromCFrame(b)}
  72. local ax, ay, az = a.x, a.y, a.z
  73. local bx, by, bz = b.x, b.y, b.z
  74. local _t = 1-t
  75. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  76. end
  77.  
  78. end
  79. do --the animating
  80. plr = game:service'Players'.LocalPlayer
  81. char = plr.Character
  82. mouse = plr:GetMouse()
  83. humanoid = char:findFirstChild("Humanoid")
  84. torso = char:findFirstChild("Torso")
  85. head = char.Head
  86. ra = char:findFirstChild("Right Arm")
  87. la = char:findFirstChild("Left Arm")
  88. rl = char:findFirstChild("Right Leg")
  89. ll = char:findFirstChild("Left Leg")
  90. rs = torso:findFirstChild("Right Shoulder")
  91. ls = torso:findFirstChild("Left Shoulder")
  92. rh = torso:findFirstChild("Right Hip")
  93. lh = torso:findFirstChild("Left Hip")
  94. neck = torso:findFirstChild("Neck")
  95. rj = char:findFirstChild("HumanoidRootPart"):findFirstChild("RootJoint")
  96. anim = char:findFirstChild("Animate")
  97. rootpart = char:findFirstChild("HumanoidRootPart")
  98. camera = workspace.CurrentCamera
  99. if anim then
  100. anim:Destroy()
  101. end
  102.  
  103.  
  104. local rm = Instance.new("Motor", torso)
  105. rm.C0 = CFrame.new(1.5, 0.5, 0)
  106. rm.C1 = CFrame.new(0, 0.5, 0)
  107. rm.Part0 = torso
  108. rm.Part1 = ra
  109. local lm = Instance.new("Motor", torso)
  110. lm.C0 = CFrame.new(-1.5, 0.5, 0)
  111. lm.C1 = CFrame.new(0, 0.5, 0)
  112. lm.Part0 = torso
  113. lm.Part1 = la
  114.  
  115. local rlegm = Instance.new("Motor", torso)
  116. rlegm.C0 = CFrame.new(0.5, -1, 0)
  117. rlegm.C1 = CFrame.new(0, 1, 0)
  118. rlegm.Part0 = torso
  119. rlegm.Part1 = rl
  120. local llegm = Instance.new("Motor", torso)
  121. llegm.C0 = CFrame.new(-0.5, -1, 0)
  122. llegm.C1 = CFrame.new(0, 1, 0)
  123. llegm.Part0 = torso
  124. llegm.Part1 = ll
  125.  
  126. neck.C0 = CFrame.new(0, 1, 0)
  127. neck.C1 = CFrame.new(0, -0.5, 0)
  128.  
  129.  
  130. rj.C0 = CFrame.new()
  131. rj.C1 = CFrame.new()
  132.  
  133.  
  134. local sound = Instance.new("Sound", head)
  135. sound.SoundId = "http://www.roblox.com/asset/?id=130797915"
  136. sound.Volume = 0.8
  137. sound.Looped = true
  138.  
  139. for i,v in pairs(char:children()) do
  140. if v:IsA("Hat") then
  141. v:Destroy()
  142. end
  143. end
  144.  
  145.  
  146. --look of the fox here
  147. game:service'InsertService':LoadAsset(151784320):children()[1].Parent = char
  148. Instance.new("PointLight", head).Range = 10
  149.  
  150.  
  151.  
  152.  
  153. local speed = 0.3
  154. local angle = 0
  155. local sitting = false
  156. local humanwalk = false
  157. local anglespeed = 1
  158. rsc0 = rm.C0
  159. lsc0 = lm.C0
  160. llc0 = llegm.C0
  161. rlc0 = rlegm.C0
  162. neckc0 = neck.C0
  163.  
  164. local controllerService = game:GetService("ControllerService")
  165. local controller = controllerService:GetChildren()[1]
  166.  
  167. controller.Parent = nil
  168.  
  169. Instance.new("HumanoidController", game:service'ControllerService')
  170. Instance.new("SkateboardController", game:service'ControllerService')
  171. Instance.new("VehicleController", game:service'ControllerService')
  172. local controller = controllerService:GetChildren()[1]
  173. mouse.KeyDown:connect(function(k)
  174. if k == "q" then
  175. humanwalk = not humanwalk
  176. end
  177. if k == "z" then
  178. if not sound.IsPlaying then
  179. sound:stop()
  180. sound.SoundId = "http://www.roblox.com/asset/?id=130802245"
  181. wait()
  182. sound:play()
  183. end
  184. end
  185. if k == "x" then
  186. if not sound.IsPlaying then
  187. sound:stop()
  188. sound.SoundId = "http://www.roblox.com/asset/?id=150794704"
  189. wait()
  190. sound:play()
  191. end
  192. end
  193. if k == "c" then
  194. if not sound.IsPlaying then
  195. sound:stop()
  196. sound.SoundId = "http://www.roblox.com/asset/?id=149713968"
  197. wait()
  198. sound:play()
  199. end
  200. end
  201. if string.byte(k) == 48 then
  202. humanoid.WalkSpeed = 55
  203. end
  204.  
  205. end)
  206. mouse.KeyUp:connect(function(k)
  207.  
  208. if string.byte(k) == 48 then
  209. humanoid.WalkSpeed = 14
  210. end
  211.  
  212. end)
  213.  
  214.  
  215.  
  216. while wait() do
  217. angle = (angle % 100) + anglespeed/10
  218. mvmnt = math.pi * math.sin(math.pi*2/100*(angle*10))
  219. local rscf = rsc0
  220. local lscf = lsc0
  221. local rlcf = rlc0
  222. local llcf = llc0
  223. local rjcf = CFrame.new()
  224. local ncf = neckc0
  225. local rayz = Ray.new(rootpart.Position, Vector3.new(0, -6, 0))
  226. local hitz, enz = workspace:findPartOnRay(rayz, char)
  227. if not hitz then
  228. if sound.IsPlaying then
  229. sound:stop()
  230. end
  231.  
  232. if Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude > 2 then
  233.  
  234. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, 0)
  235. rjcf = CFrame.new() * CFrame.Angles(-math.pi/5, math.sin(angle)*0.05, 0)
  236. rscf = rsc0 * CFrame.Angles(math.pi/1.7+math.sin(angle)*0.1, 0, 0)
  237. lscf = lsc0 * CFrame.Angles(math.pi/1.7+math.sin(-angle)*0.1, 0, 0)
  238. rlcf = rlc0 * CFrame.Angles(-math.pi/10+math.sin(-angle)*0.3, 0, 0)
  239. llcf = llc0 * CFrame.Angles(-math.pi/10+math.sin(angle)*0.3, 0, 0)
  240.  
  241. else
  242.  
  243. ncf = neckc0 * CFrame.Angles(math.pi/14, 0, 0)
  244. rjcf = CFrame.new() * CFrame.Angles(-math.pi/18, math.sin(angle)*0.05, 0)
  245. rscf = rsc0 * CFrame.Angles(-math.pi/10+math.sin(angle)*0.2, 0, 0)
  246. lscf = lsc0 * CFrame.Angles(-math.pi/10+math.sin(-angle)*0.2, 0, 0)
  247. rlcf = rlc0 * CFrame.new(0, 0.7, -0.5) CFrame.Angles(-math.pi/14, 0, 0)
  248. llcf = llc0 * CFrame.Angles(-math.pi/20, 0, 0)
  249.  
  250. end
  251. elseif humanoid.Sit then
  252. if sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=150794704" then
  253. anglespeed = 6
  254. ncf = neckc0 * CFrame.Angles(math.pi/5-math.sin(angle)*0.1, 0, 0)
  255. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, 0, 0)
  256. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  257. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  258. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  259. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  260. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=135570347" then
  261. anglespeed = 4
  262. ncf = neckc0 * CFrame.Angles(math.pi/5-math.abs(math.sin(angle))*0.3, 0, 0)
  263. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, 0, 0)
  264. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  265. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  266. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  267. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  268. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=149713968" then
  269. anglespeed = 2
  270. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  271. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  272. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  273. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  274. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  275. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  276. else
  277. anglespeed = 1/2
  278. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  279. rjcf = CFrame.new(0, -0.8, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  280. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  281. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  282. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  283. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  284. end
  285. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude < 2 then
  286. if sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=130797915" then
  287. anglespeed = 6
  288. ncf = neckc0 * CFrame.Angles(math.pi/10-math.sin(angle)*0.07, 0, 0)
  289. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(-math.pi/10, math.sin(angle)*0.001, 0)
  290. rscf = rsc0 * CFrame.Angles(math.pi/1+math.sin(angle)*0.5, 0, 0)
  291. lscf = lsc0 * CFrame.Angles(math.pi/1+math.sin(angle)*0.5, 0, 0)
  292. rlcf = rlc0 * CFrame.Angles(math.pi/10, math.sin(angle)*0.08, math.rad(6.5))
  293. llcf = llc0 * CFrame.Angles(math.pi/10, -math.sin(angle)*0.08, -math.rad(6.5))
  294. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=149713968" then
  295. anglespeed = 2
  296. ncf = neckc0 * CFrame.Angles(math.pi/10-math.abs(math.sin(angle))*0.3, 0, 0)
  297. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(-math.pi/20, math.sin(angle)*0.001, 0)
  298. rscf = rsc0 * CFrame.Angles(math.pi/2+math.abs(math.sin(angle)*1), 0, 0)
  299. lscf = lsc0 * CFrame.Angles(math.pi/2+math.abs(math.sin(angle)*1), 0, 0)
  300. rlcf = rlc0 * CFrame.Angles(math.pi/20, math.sin(angle)*0.08, math.rad(2.5))
  301. llcf = llc0 * CFrame.Angles(math.pi/20, -math.sin(angle)*0.08, -math.rad(2.5))
  302. elseif sound.IsPlaying and sound.SoundId == "http://www.roblox.com/asset/?id=130802245" then
  303. anglespeed = 3
  304. ncf = neckc0 * CFrame.Angles(math.sin(angle)*0.07, math.rad(30), 0)
  305. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(0, math.sin(angle)*0.001, 0)
  306. rscf = rsc0 * CFrame.Angles(math.sin(angle)*0.05, 0, 0)
  307. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*0.05, 0, 0)
  308. rlcf = rlc0 * CFrame.new(0, -0.1 + math.abs(mvmnt)*0.1, -0.1) * CFrame.Angles(0, math.rad(5), math.rad(5))
  309. llcf = llc0 * CFrame.Angles(0, math.rad(2.5), math.rad(1))
  310. else
  311. if humanwalk then
  312. anglespeed = 1/4
  313. ncf = neckc0 * CFrame.Angles(-math.sin(angle)*0.07, 0, 0)
  314. rjcf = CFrame.new(0, 0, 0) * CFrame.Angles(0, math.sin(angle)*0.001, 0)
  315. rscf = rsc0 * CFrame.Angles(math.sin(angle)*0.1, 0, 0)
  316. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*0.1, 0, 0)
  317. rlcf = rlc0 * CFrame.Angles(0, math.sin(angle)*0.08, math.rad(2.5))
  318. llcf = llc0 * CFrame.Angles(0, -math.sin(angle)*0.08, -math.rad(2.5))
  319. else
  320. anglespeed = 1/2
  321. ncf = neckc0 * CFrame.Angles(math.pi/5, 0, math.sin(angle)*0.08)
  322. rjcf = CFrame.new(0, -2, 0) * CFrame.Angles(-math.pi/5, math.sin(angle)*0.01, 0)
  323. rscf = rsc0 * CFrame.new(-.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, -math.rad(15))
  324. lscf = lsc0 * CFrame.new(.45, 0.2, -.3) * CFrame.Angles(math.pi/3, 0, math.rad(15))
  325. rlcf = rlc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, math.rad(20))
  326. llcf = llc0 * CFrame.Angles(math.pi/2+math.pi/5, 0, -math.rad(20))
  327. end
  328. end
  329. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude < 20 then
  330. if sound.IsPlaying then
  331. sound:stop()
  332. end
  333. if humanwalk then
  334. anglespeed = 4
  335. ncf = neckc0 * CFrame.Angles(math.pi/24, mvmnt*.02, 0)
  336. rjcf = CFrame.new(0, math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/24, -mvmnt*.02, 0)
  337. rscf = rsc0 * CFrame.Angles(math.sin(angle)*1.25, 0, -math.abs(mvmnt)*0.02)
  338. lscf = lsc0 * CFrame.Angles(math.sin(-angle)*1.25, 0, math.abs(mvmnt)*0.02)
  339. rlcf = rlc0 * CFrame.Angles(math.sin(-angle)*1, 0, math.rad(.5))
  340. llcf = llc0 * CFrame.Angles(math.sin(angle)*1, 0, -math.rad(.5))
  341. else
  342. anglespeed = 4
  343. ncf = neckc0 * CFrame.new(0, 0, .2) * CFrame.Angles(math.pi/1.9, 0, 0)
  344. rjcf = CFrame.new(0, -1.5+math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/1.9, math.sin(mvmnt/2)*0.05, 0)
  345. rscf = rsc0 * CFrame.new(-.45, 0.2, -.4+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2+math.sin(angle)*0.7, 0, math.rad(5))
  346. lscf = lsc0 * CFrame.new(.45, 0.2, .1-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2+math.sin(-angle)*0.7, 0, -math.rad(5))
  347. rlcf = rlc0 * CFrame.new(0, 0, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*0.6, 0, math.abs(mvmnt)*0.025)
  348. llcf = llc0 * CFrame.new(0, 0, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(angle)*.6, 0, -math.abs(mvmnt)*0.025)
  349. end
  350. elseif Vector3.new(torso.Velocity.x, 0, torso.Velocity.z).magnitude >= 20 then
  351. if sound.IsPlaying then
  352. sound:stop()
  353. end
  354. if humanwalk then
  355. anglespeed = 5
  356. ncf = neckc0 * CFrame.Angles(math.pi/20, math.sin(angle)*.04, 0)
  357. rjcf = CFrame.new(0, -.4 + math.abs(mvmnt)*0.25, 0) * CFrame.Angles(-math.pi/20, -math.sin(angle)*.08, 0)
  358. rscf = rsc0 * CFrame.new(0, 0, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/18+math.sin(angle)*1.5, 0, -math.abs(mvmnt)*0.02)
  359. lscf = lsc0 * CFrame.new(0, 0, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/18+math.sin(-angle)*1.5, 0, math.abs(mvmnt)*0.02)
  360. rlcf = rlc0 * CFrame.new(0, 0, -.6+math.abs(mvmnt)*0.125) * CFrame.Angles(-math.pi/18+math.sin(-angle)*1.3, 0, math.rad(.5))
  361. llcf = llc0 * CFrame.new(0, 0, -math.abs(mvmnt)*0.125) * CFrame.Angles(-math.pi/18+math.sin(angle)*1.3, 0, -math.rad(.5))
  362. else
  363. anglespeed = 5.5
  364. ncf = neckc0 * CFrame.new(0, 0, .2) * CFrame.Angles(math.pi/1.9+math.sin(mvmnt/2)*0.05, 0, 0)
  365. rjcf = CFrame.new(0, -1.3+math.abs(mvmnt)*0.05, 0) * CFrame.Angles(-math.pi/1.9+math.abs(mvmnt/2)*0.1, 0, 0)
  366. rscf = rsc0 * CFrame.new(-1, 0.2, -.5) * CFrame.Angles(math.pi/2+math.sin(angle)*1.8, 0, math.rad(5))
  367. lscf = lsc0 * CFrame.new(1, 0.2, -.5) * CFrame.Angles(math.pi/2+math.sin(angle)*1.8, 0, -math.rad(5))
  368. rlcf = rlc0 * CFrame.new(0, .3-math.abs(mvmnt)*0.125, -.3+math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*1.4, 0, math.abs(mvmnt)*0.025)
  369. llcf = llc0 * CFrame.new(0, .3-math.abs(mvmnt)*0.125, .3-math.abs(mvmnt)*0.125) * CFrame.Angles(math.pi/2.5+math.sin(-angle)*1.4, 0, -math.abs(mvmnt)*0.025)
  370. end
  371. end
  372.  
  373. rm.C0 = clerp(rm.C0,rscf,speed)
  374. lm.C0 = clerp(lm.C0,lscf,speed)
  375. rj.C0 = clerp(rj.C0,rjcf,speed)
  376. neck.C0 = clerp(neck.C0,ncf,speed)
  377. rlegm.C0 = clerp(rlegm.C0,rlcf,speed)
  378. llegm.C0 = clerp(llegm.C0,llcf,speed)
  379. end
  380.  
  381.  
  382. end
Add Comment
Please, Sign In to add comment