Advertisement
lafur

Untitled

Aug 28th, 2020 (edited)
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.61 KB | None | 0 0
  1. local plr = owner
  2. local char = plr.Character
  3. local hum = char:FindFirstChildOfClass("Humanoid")
  4. local torso = char:FindFirstChild("Torso")
  5. local rootpart = char:FindFirstChild("HumanoidRootPart")
  6. local larm,rarm,lleg,rleg,head = char:FindFirstChild("Left Arm"),char:FindFirstChild("Right Arm"),char:FindFirstChild("Left Leg"),char:FindFirstChild("Right Leg"),char:FindFirstChild("Head")
  7. if larm and rarm and lleg and rleg and head--[[hum.RigType ~= Enum.HumanoidRigType.R6]] then else warn('Character must be R6.'); return; end;
  8.  
  9. ls,rs,lh,rh,neck,rj = torso:FindFirstChild("Left Shoulder"),torso:FindFirstChild("Right Shoulder"),torso:FindFirstChild("Left Hip"),torso:FindFirstChild("Right Hip"),torso:FindFirstChild("Neck"),rootpart:FindFirstChild("RootJoint")
  10.  
  11. function QuaternionFromCFrame(cf)
  12. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  13. local trace = m00 + m11 + m22
  14. if trace > 0 then
  15. local s = math.sqrt(1 + trace)
  16. local recip = 0.5 / s
  17. return (m21 - m12) * recip, (m02 - m20) * recip, (m10 - m01) * recip, s * 0.5
  18. else
  19. local i = 0
  20. if m11 > m00 then
  21. i = 1
  22. end
  23. if m22 > (i == 0 and m00 or m11) then
  24. i = 2
  25. end
  26. if i == 0 then
  27. local s = math.sqrt(m00 - m11 - m22 + 1)
  28. local recip = 0.5 / s
  29. return 0.5 * s, (m10 + m01) * recip, (m20 + m02) * recip, (m21 - m12) * recip
  30. elseif i == 1 then
  31. local s = math.sqrt(m11 - m22 - m00 + 1)
  32. local recip = 0.5 / s
  33. return (m01 + m10) * recip, 0.5 * s, (m21 + m12) * recip, (m02 - m20) * recip
  34. elseif i == 2 then
  35. local s = math.sqrt(m22 - m00 - m11 + 1)
  36. local recip = 0.5 / s return (m02 + m20) * recip, (m12 + m21) * recip, 0.5 * s, (m10 - m01) * recip
  37. end
  38. end
  39. end
  40.  
  41. function QuaternionToCFrame(px, py, pz, x, y, z, w)
  42. local xs, ys, zs = x + x, y + y, z + z
  43. local wx, wy, wz = w * xs, w * ys, w * zs
  44. local xx = x * xs
  45. local xy = x * ys
  46. local xz = x * zs
  47. local yy = y * ys
  48. local yz = y * zs
  49. local zz = z * zs
  50. 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))
  51. end
  52.  
  53. function QuaternionSlerp(a, b, t)
  54. local cosTheta = a[1] * b[1] + a[2] * b[2] + a[3] * b[3] + a[4] * b[4]
  55. local startInterp, finishInterp;
  56. if cosTheta >= 0.0001 then
  57. if (1 - cosTheta) > 0.0001 then
  58. local theta = math.acos(cosTheta)
  59. local invSinTheta = 1 / math.sin(theta)
  60. startInterp = math.sin((1 - t) * theta) * invSinTheta
  61. finishInterp = math.sin(t * theta) * invSinTheta
  62. else
  63. startInterp = 1 - t
  64. finishInterp = t
  65. end
  66. else
  67. if (1 + cosTheta) > 0.0001 then
  68. local theta = math.acos(-cosTheta)
  69. local invSinTheta = 1 / math.sin(theta)
  70. startInterp = math.sin((t - 1) * theta) * invSinTheta
  71. finishInterp = math.sin(t * theta) * invSinTheta
  72. else
  73. startInterp = t - 1
  74. finishInterp = t
  75. end
  76. end
  77. 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
  78. end
  79.  
  80. function clerp(a, b, t)
  81. local qa = {QuaternionFromCFrame(a)}
  82. local qb = {QuaternionFromCFrame(b)}
  83. local ax, ay, az = a.x, a.y, a.z
  84. local bx, by, bz = b.x, b.y, b.z
  85. local _t = 1 - t
  86. return QuaternionToCFrame(_t * ax + t * bx, _t * ay + t * by, _t * az + t * bz, QuaternionSlerp(qa, qb, t))
  87. end
  88.  
  89. function lerp(a,b,t)
  90. a:lerp(b,t)
  91. end
  92.  
  93. --//=================================\\
  94. --|| SAZERENOS' ARTIFICIAL HEARTBEAT
  95. --\\=================================//
  96.  
  97. ArtificialHB = Instance.new("BindableEvent", script)
  98. ArtificialHB.Name = "ArtificialHB"
  99.  
  100. script:WaitForChild("ArtificialHB")
  101.  
  102. frame = (1/60)
  103. tf = 0
  104. allowframeloss = false
  105. tossremainder = false
  106. lastframe = tick()
  107. script.ArtificialHB:Fire()
  108.  
  109. game:GetService("RunService").Heartbeat:connect(function(s, p)
  110. tf = tf + s
  111. if tf >= frame then
  112. if allowframeloss then
  113. script.ArtificialHB:Fire()
  114. lastframe = tick()
  115. else
  116. for i = 1, math.floor(tf / frame) do
  117. script.ArtificialHB:Fire()
  118. end
  119. lastframe = tick()
  120. end
  121. if tossremainder then
  122. tf = 0
  123. else
  124. tf = tf - frame * math.floor(tf / frame)
  125. end
  126. end
  127. end)
  128.  
  129. function Swait(NUMBER)
  130. if NUMBER == 0 or NUMBER == nil then
  131. ArtificialHB.Event:wait()
  132. else
  133. for i = 1, NUMBER do
  134. ArtificialHB.Event:wait()
  135. end
  136. end
  137. end
  138.  
  139. --//=================================\\
  140. --\\=================================//
  141.  
  142. local motors = {}
  143. local welds = {}
  144.  
  145. if ls then
  146. table.insert(motors,1,{ls,ls.Parent})
  147. ls.Parent = nil
  148. ls = Instance.new("Weld")
  149. ls.Name = 'Left Shoulder'
  150. ls.Part0 = torso
  151. ls.Part1 = larm
  152. ls.Parent = torso
  153. table.insert(welds,1,{ls,ls.Parent})
  154. end
  155.  
  156. if rs then
  157. table.insert(motors,1,{rs,rs.Parent})
  158. rs.Parent = nil
  159. rs = Instance.new("Weld")
  160. rs.Name = 'Right Shoulder'
  161. rs.Part0 = torso
  162. rs.Part1 = rarm
  163. rs.Parent = torso
  164. table.insert(welds,1,{rs,rs.Parent})
  165. end
  166.  
  167. if lh then
  168. table.insert(motors,1,{lh,lh.Parent})
  169. lh.Parent = nil
  170. lh = Instance.new("Weld")
  171. lh.Name = 'Left Hip'
  172. lh.Part0 = torso
  173. lh.Part1 = lleg
  174. lh.Parent = torso
  175. table.insert(welds,1,{lh,lh.Parent})
  176. end
  177.  
  178. if rh then
  179. table.insert(motors,1,{rh,rh.Parent})
  180. rh.Parent = nil
  181. rh = Instance.new("Weld")
  182. rh.Name = 'Right Hip'
  183. rh.Part0 = torso
  184. rh.Part1 = rleg
  185. rh.Parent = torso
  186. table.insert(welds,1,{rh,rh.Parent})
  187. end
  188.  
  189. if neck then
  190. table.insert(motors,1,{neck,neck.Parent})
  191. neck.Parent = nil
  192. neck = Instance.new("Weld")
  193. neck.Name = 'Neck'
  194. neck.Part0 = torso
  195. neck.Part1 = head
  196. neck.Parent = torso
  197. table.insert(welds,1,{neck,neck.Parent})
  198. end
  199.  
  200. if rj then
  201. table.insert(motors,1,{rj,rj.Parent})
  202. rj.Parent = nil
  203. rj = Instance.new("Weld")
  204. rj.Name = 'RootJoint'
  205. rj.Part0 = rootpart
  206. rj.Part1 = torso
  207. rj.Parent = torso
  208. table.insert(welds,1,{rj,rj.Parent})
  209. end
  210. local tool=Instance.new("HopperBin", game.Players.lafur2.Backpack)
  211. tool.Name="Knife"
  212.  
  213. wait()
  214. script.Parent=tool
  215.  
  216. --Murderer knife action script, original code from The Mad Murderer, by loleris.
  217.  
  218. wait()
  219. local camera = game.Workspace.CurrentCamera
  220. local player = game.Players.lafur2
  221. local character = player.Character
  222. local humanoid = character.Humanoid
  223. local head = character.Head
  224. local torso = character.Torso
  225. local pl_mouse = player:GetMouse()
  226.  
  227. local rs = game:GetService("RunService")
  228.  
  229. local stab_damage = 110
  230. local walkspeeds = {16, 19}
  231.  
  232. Settings = {
  233. Equip_time = 0.4,
  234. Idle_speed = 5,
  235. Attack_speed = 0.65,
  236. }
  237.  
  238. local assetlink = "http://www.roblox.com/asset/?id="
  239. local hit_sounds = {"153647516", "153647519", "153647522", "153647526"}
  240. local death_sounds = {"146594640", "146594648", "146457047"}
  241. function Clean(obj)
  242. spawn(function()
  243. wait(6)
  244. obj:remove()
  245. end)
  246. end
  247.  
  248. function HIT_HANDLE(hit, dmg, pos)
  249. if hit == nil then return end
  250. local h = hit.Parent:findFirstChild("Humanoid")
  251. if h == nil then
  252. h = hit.Parent.Parent:findFirstChild("Humanoid")
  253. end
  254. if h == nil then return end
  255. if h.Health <= 0 then return end
  256.  
  257. local head = h.Parent:findFirstChild("Head")
  258. if head == nil then return end
  259.  
  260. local sound_part = Instance.new("Part")
  261. sound_part.formFactor = "Custom"
  262. sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  263. sound_part.Transparency = 1
  264. sound_part.CanCollide = false
  265. sound_part.Anchored = true
  266. sound_part.CFrame = head.CFrame
  267. Clean(sound_part)
  268. sound_part.Parent = Workspace
  269. local s_hit = Instance.new("Sound")
  270. s_hit.Volume = 1
  271. s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  272. s_hit.Parent = sound_part
  273. local s_die = Instance.new("Sound")
  274. s_die.Volume = 1
  275. s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  276. s_die.Parent = sound_part
  277.  
  278. s_hit:play()
  279.  
  280. local c_tag = Instance.new("ObjectValue")
  281. c_tag.Name = "creator"
  282. c_tag.Value = player
  283. c_tag.Parent = h
  284. h.Health=0
  285. s_die:play()
  286. end
  287.  
  288. function GENERATE_IGNORELIST()
  289. local result = {character, camera}
  290. local plr = game.Players:GetPlayers()
  291. for i = 1, #plr do
  292. if plr[i] ~= player then
  293. local char = plr[i].Character
  294. if char ~= nil then
  295. local ch = char:GetChildren()
  296. for i = 1, #ch do
  297. if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then
  298. result[#result + 1] = ch[i]
  299. end
  300. end
  301. end
  302. end
  303. end
  304. return result
  305. end
  306.  
  307. function RayCast(pos1, pos2, dist, ign)
  308. local ray = Ray.new(
  309. pos1,
  310. (pos2 - pos1).unit * math.abs(dist)
  311. )
  312. local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  313. return hit, hpos
  314. end
  315.  
  316. local larm = character:findFirstChild("Left Arm")
  317. local rarm = character:findFirstChild("Right Arm")
  318. function Slash(del)
  319. coroutine.resume(coroutine.create(function()
  320. local hits = {}
  321.  
  322. local start = tick()
  323. local actv = true
  324.  
  325. local function ishitted(obj)
  326. for i = 1, #hits do
  327. if obj:IsDescendantOf(hits[i]) then
  328. return true
  329. end
  330. end
  331. return false
  332. end
  333.  
  334. local function hitp(hit)
  335. if ishitted(hit) then return end
  336. local h = hit.Parent:findFirstChild("Humanoid")
  337. if h == nil then
  338. h = hit.Parent.Parent:findFirstChild("Humanoid")
  339. end
  340. if h == nil then return end
  341. hits[#hits + 1] = h.Parent
  342. HIT_HANDLE(hit, stab_damage)
  343. end
  344.  
  345. local con = {
  346. larm.Touched:connect(hitp),
  347. rarm.Touched:connect(hitp),
  348. }
  349.  
  350. while tick() - start <= Settings.Attack_speed do wait() end
  351. actv = false
  352. con[1]:disconnect()
  353. con[2]:disconnect()
  354. end))
  355. end
  356.  
  357. local dg_sounds = {
  358. equip = {
  359. "153647514"
  360. },
  361. hit = {
  362. "153647516",
  363. "153647519",
  364. "153647522",
  365. "153647526"
  366. },
  367. swing = {
  368. "153647529",
  369. "153647534",
  370. "153647539",
  371. "153647540"
  372. }
  373. }
  374.  
  375. local dg_soundobj = {}
  376. for k, v in pairs(dg_sounds) do
  377. dg_soundobj[k] = {}
  378. for i = 1, #v do
  379. local ns = Instance.new("Sound")
  380. ns.SoundId = assetlink .. v[i]
  381. ns.Volume = 1
  382. dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  383. end
  384. end
  385.  
  386. function LoadSounds()
  387. for __, v in pairs(dg_soundobj) do
  388. for i = 1, #v do
  389. v[i].Parent = head
  390. end
  391. end
  392. end
  393. function RemoveSounds()
  394. for __, v in pairs(dg_soundobj) do
  395. for i = 1, #v do
  396. v[i].Parent = nil
  397. end
  398. end
  399. end
  400. function PlaySound(nm, dl)
  401. if dl == nil then
  402. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  403. else
  404. coroutine.resume(coroutine.create(function()
  405. wait(dl)
  406. dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  407. end))
  408. end
  409. end
  410.  
  411. _G.MurderKnife_AnimType = "Default"
  412. _G.MurderKnife_AnimState = 0
  413.  
  414. function Animate(tp, st)
  415. _G.MurderKnife_AnimType = tp
  416. _G.MurderKnife_AnimState = st
  417. end
  418.  
  419. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2
  420. humanoid.WalkSpeed = walkspeeds[2]
  421. mouse.Icon = assetlink .. "54019936"
  422. Animate("Equip", 0)
  423. LoadSounds()
  424. PlaySound("equip", 0.1)
  425.  
  426. local anim_equip = 1
  427. local last_action = tick()
  428. local idle_rand = math.random(4, 7)
  429. local idle_perform = 0
  430. local idle_type = 1
  431.  
  432. local attack_perform = 0
  433. local attack_type = 1
  434.  
  435. local running = true
  436. local last_c = tick()
  437.  
  438. local click_start = tick()
  439. mouse.Button1Down:connect(function()
  440. if not running or anim_equip > 0 then return end
  441. if tick() - attack_perform <= Settings.Attack_speed then return end
  442. attack_perform = tick()
  443. last_action = tick()
  444. attack_type = math.random(1, 3)
  445. idle_perform = 0
  446. PlaySound("swing", 0.15)
  447. Slash(0.17)
  448. end)
  449.  
  450. local conn = rs.RenderStepped:connect(function()
  451. if not running then return end
  452. local delta = tick() - last_c
  453. last_c = tick()
  454.  
  455. if anim_equip > 0 then
  456. anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time))
  457. Animate("Equip", 1 - anim_equip)
  458. elseif tick() - attack_perform <= Settings.Attack_speed then
  459. Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  460. idle_perform = 0
  461. elseif tick() - idle_perform <= Settings.Idle_speed then
  462. Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  463. else
  464. Animate("Default", 0)
  465. end
  466.  
  467. if tick() - last_action >= idle_rand then
  468. idle_rand = math.random(12, 20)
  469. last_action = tick()
  470. idle_perform = tick()
  471. idle_type = math.random(1, 2)
  472. end
  473.  
  474. end)
  475. tool.Deselected:connect(function() running = false conn:disconnect() end)
  476. end)
  477. tool.Deselected:connect(function()
  478. RemoveSounds()
  479. humanoid.WalkSpeed = walkspeeds[1]
  480. end)
  481.  
  482. --Murderer knife animation module, original code from The Mad Murderer, by loleris.
  483.  
  484. local mouse = pl_mouse
  485.  
  486. local conn_type = "Snap"
  487.  
  488. local anim_head = false
  489.  
  490. weapon_properties = {
  491. mesh_id = "http://www.roblox.com/asset/?id=121944778",
  492. texture_id = "http://www.roblox.com/asset/?id=121944805",
  493. scale = Vector3.new(0.6, 0.6, 0.6),
  494. transparency = 0,
  495. reflectance = 0,
  496. brick_color = BrickColor.new("Really black"),
  497. }
  498.  
  499. --How did I make all of this? Magic. Didn't even need an animation editor :)
  500. Animations = {
  501. Default = {
  502. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  503. },
  504. Equip = {
  505. {{}, 0, CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, 0, 0) * CFrame.Angles(-1.571, 0, 0), CFrame.new(0, -1.3, -0.5) * CFrame.Angles(-2.618, 0, 0)},
  506. {{0.8, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  507. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  508. },
  509. Idle1 = {
  510. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  511. {{0.3, 2}, 0, CFrame.new(0.8, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.523, 1.221, -0.699), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 1.221, 0)},
  512. {{0.55, 2}, 0, CFrame.new(0.2, -0.5, 0.2) * CFrame.Angles(-0.14, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0, 1.221, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.746, 1.221, 0.174)},
  513. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  514. },
  515. Idle2 = {
  516. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  517. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.524, 0, 0.872), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, -0.175, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0.523, 0)},
  518. {{0.3, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.349, 0, 0.523), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.174, 0.698, -0.524), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  519. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(0.61, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.139, 0.663, -0.489), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, -1.222, 0)},
  520. {{0.2, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  521. },
  522. Attack1 = {
  523. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  524. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, 0.349), CFrame.new(-0.201, 0, 0) * CFrame.Angles(0.872, 0.349, 0.087), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  525. {{0.15, 2}, 0, CFrame.new(0.4, -0.101, 0.1) * CFrame.Angles(-1.571, 0, -0.35), CFrame.new(-0.301, -0.301, 0.1) * CFrame.Angles(-1.048, -0.175, -0.524), CFrame.new(0, -1.201, -0.801) * CFrame.Angles(-2.095, 0, 0)},
  526. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  527. },
  528. Attack2 = {
  529. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  530. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.401, 0.3, 0.1) * CFrame.Angles(1.919, 2.443, -1.222), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  531. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.048, 0, -0.524), CFrame.new(-0.5, -0.201, -0.101) * CFrame.Angles(0.523, 1.396, -0.873), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  532. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)}
  533. },
  534. Attack3 = {
  535. {{}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  536. {{0.25, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, -0.201, 0) * CFrame.Angles(1.396, 0.698, -1.571), CFrame.new(0, -1.3, -0.401) * CFrame.Angles(-2.444, 0, 0)},
  537. {{0.15, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-1.397, 0, 0.174), CFrame.new(-0.401, 0.1, 0) * CFrame.Angles(0.349, 2.094, -0.524), CFrame.new(0, -1.3, 0.1) * CFrame.Angles(-3.84, 0, 0)},
  538. {{0.6, 2}, 0, CFrame.new(0.4, -0.201, 0.2) * CFrame.Angles(-0.873, 0, 0.698), CFrame.new(-0.201, 0, 0) * CFrame.Angles(-0.175, 0.349, -0.262), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)} --Psst. Create a dummy, try setting position and angles of limbs and the weapon, save CFrame data to code. Easy? Yes. When making a single knife tool, it was all you needed.
  539. }
  540. }
  541.  
  542.  
  543. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  544. local Diff2 = GetCFrame2.p - GetCFrame1.p
  545. GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  546. GetCFrame2 = GetCFrame2 - GetCFrame2.p
  547. local Diff = GetCFrame1_s:inverse() * GetCFrame2
  548. local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  549. return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  550. end
  551.  
  552. function TransEff(x, type)
  553. if type == 1 then
  554. return x
  555. elseif type == 2 then
  556. return x*x*(3 - 2*x)
  557. elseif type == 3 then
  558. return math.sin(math.rad(x * 90))
  559. elseif type == 4 then
  560. return 1 - math.sin(math.rad((1 - x) * 90))
  561. end
  562. end
  563.  
  564. function num_trans(n1, n2, x)
  565. return n1 + ((n2 - n1) * x)
  566. end
  567.  
  568. function PlayAnimation(anim_name, tm) --return {left, right, wep, trans}
  569. tm = math.min(1, math.max(0, tm))
  570. local animd = Animations[anim_name]
  571. if #animd == 1 then
  572. return {animd[1][3], animd[1][4], animd[1][5], animd[1][2]}
  573. else
  574. local trans_from = 1
  575. local trans_to = 1
  576. local tm_left = tm
  577. for i = 2, #animd do
  578. tm_left = tm_left - animd[i][1][1]
  579. if tm_left <= 0 then
  580. trans_from = i - 1
  581. trans_to = i
  582. break
  583. end
  584. end
  585. local trans_amm = TransEff((animd[trans_to][1][1] + tm_left) / animd[trans_to][1][1], animd[trans_to][1][2])
  586. return {
  587. CFrameTrans(animd[trans_from][3], animd[trans_to][3], trans_amm),
  588. CFrameTrans(animd[trans_from][4], animd[trans_to][4], trans_amm),
  589. CFrameTrans(animd[trans_from][5], animd[trans_to][5], trans_amm),
  590. num_trans(animd[trans_from][2], animd[trans_to][2], trans_amm)
  591. }
  592. end
  593. end
  594.  
  595. rot_amplitude_head = 20
  596. rot_amplitude_chest = 15
  597.  
  598. anim_p = {
  599. cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  600. aim_amp = 0.5,
  601. aim_max_change = 4,
  602. aim_retract = 15,
  603. aim_max_deg = 20,
  604. }
  605.  
  606. local weapon_model = Instance.new("Part")
  607. weapon_model.CanCollide = false
  608. weapon_model.Name = "WeaponObject"
  609. weapon_model.formFactor = "Custom"
  610. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  611. weapon_model.TopSurface = 0
  612. weapon_model.BottomSurface = 0
  613. weapon_model.BrickColor = weapon_properties.brick_color
  614. weapon_model.Transparency = weapon_properties.transparency
  615. weapon_model.Reflectance = weapon_properties.reflectance
  616. local mesh = Instance.new("SpecialMesh", weapon_model)
  617. mesh.Scale = weapon_properties.scale
  618. mesh.MeshId = weapon_properties.mesh_id
  619. mesh.TextureId = weapon_properties.texture_id
  620.  
  621. torso = character.Torso
  622. head = character.Head
  623.  
  624. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  625. welds = {nil, nil, nil}
  626. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  627. weapon_model = nil
  628.  
  629. function EndAnimation()
  630. if motors[1] then
  631. motors[1].Part1 = character:findFirstChild("Left Arm")
  632. end
  633. if motors[2] then
  634. motors[2].Part1 = character:findFirstChild("Right Arm")
  635. end
  636. if motors[3] then
  637. motors[3].Part1 = character:findFirstChild("Head")
  638. end
  639. if welds[1] then
  640. welds[1]:remove()
  641. welds[1] = nil
  642. end
  643. if welds[2] then
  644. welds[2]:remove()
  645. welds[2] = nil
  646. end
  647. if welds[3] then
  648. welds[3]:remove()
  649. welds[3] = nil
  650. end
  651. weapon_parts[1].Parent = nil
  652. if weapon_model then
  653. weapon_model.Parent = nil
  654. end
  655. coroutine.resume(coroutine.create(function()
  656. local swm = weapon_model
  657. wait()
  658. swm.Parent = nil
  659. wait(0.1)
  660. swm.Parent = nil
  661. wait(0.5)
  662. swm.Parent = nil
  663. end))
  664. end
  665.  
  666. local anim_model = Instance.new("Model")
  667. anim_model.Name = "WeaponAnimation"
  668. weapon_model = anim_model
  669.  
  670. local cam_larm = Instance.new("Part")
  671. cam_larm.Parent = anim_model
  672. cam_larm.BrickColor = BrickColor.new("Really black")
  673. cam_larm.formFactor = "Custom"
  674. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  675. cam_larm.TopSurface = 0
  676. cam_larm.BottomSurface = 0
  677. cam_larm.Transparency = 0.4
  678. cam_larm.CanCollide = false
  679. local hmesh = Instance.new("BlockMesh", cam_larm)
  680. hmesh.Scale = Vector3.new(5, 10, 5)
  681.  
  682. local cam_rarm = cam_larm:clone()
  683. cam_rarm.Parent = anim_model
  684.  
  685. function StartAnimation()
  686. local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  687. if check[1] then check[1]:remove() end
  688. if check[2] then check[2]:remove() end
  689. if check[3] then check[3]:remove() end
  690. local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  691. if check2[1] then check2[1].Parent = nil end
  692. if check2[2] then check2[2].Parent = nil end
  693. if motors[1] then
  694. motors[1].Part1 = nil
  695. end
  696. if motors[2] then
  697. motors[2].Part1 = nil
  698. end
  699. if motors[3] then
  700. motors[3].Part1 = nil
  701. end
  702. welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  703. welds[1].Part0 = torso
  704. welds[2].Part0 = torso
  705. welds[3].Part0 = torso
  706. welds[1].Part1 = character:findFirstChild("Left Arm")
  707. welds[2].Part1 = character:findFirstChild("Right Arm")
  708. welds[3].Part1 = character:findFirstChild("Head")
  709. welds[1].Name = "LeftWeld"
  710. welds[2].Name = "RightWeld"
  711. welds[2].Name = "HeadWeld"
  712. welds[1].C0 = CFrame.new(-1.5, 0, 0)
  713. welds[2].C0 = CFrame.new(1.5, 0, 0)
  714. welds[3].C0 = CFrame.new(0, 1.5, 0)
  715. welds[1].Parent = torso
  716. welds[2].Parent = torso
  717. welds[3].Parent = torso
  718.  
  719. weapon_parts[1].Parent = character
  720. local wep_weld = Instance.new(conn_type)
  721. wep_weld.Part0 = character:findFirstChild("Right Arm")
  722. wep_weld.Part1 = weapon_parts[1]
  723. wep_weld.C0 = CFrame.new()
  724. wep_weld.Parent = weapon_parts[1]
  725.  
  726. local weld1 = welds[1]
  727. local weld2 = welds[2]
  728. local weld3 = welds[3]
  729.  
  730. local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  731. cam_welds[1].Part0 = torso
  732. cam_welds[1].Part1 = cam_larm
  733. cam_welds[1].Parent = cam_larm
  734. cam_welds[2].Part0 = torso
  735. cam_welds[2].Part1 = cam_rarm
  736. cam_welds[2].Parent = cam_rarm
  737. cam_welds[3].Part0 = cam_rarm
  738. cam_welds[3].Part1 = weapon_parts[2]
  739. cam_welds[3].Parent = weapon_parts[2]
  740. weapon_parts[2].Parent = anim_model
  741.  
  742. local move_anim_speed = 3
  743. local last_p = Vector3.new()
  744. local move_amm = 0
  745. coroutine.resume(coroutine.create(function()
  746. while weld1.Parent ~= nil do
  747. local delta = wait(1/25)
  748. local cur_p = torso.Position
  749. if (cur_p - last_p).magnitude >= 0.1 then
  750. move_amm = math.min(1, move_amm + delta * move_anim_speed)
  751. else
  752. move_amm = math.max(0, move_amm - delta * move_anim_speed)
  753. end
  754. last_p = cur_p
  755. end
  756. end))
  757.  
  758. local r_serv = game:GetService("RunService")
  759.  
  760. --EASTER EGG
  761. function easein(x)
  762. return math.sin(math.rad(x * 90))
  763. end
  764.  
  765. local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  766. local horse_displace = {0, 0}
  767. local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  768. if a_horse then
  769. coroutine.resume(coroutine.create(function()
  770. while weld1.Parent ~= nil do
  771. local rndwait = (math.random(100, 1000) / 1000) * 4
  772. wait(rndwait)
  773. local oldd = {horse_displace[1], horse_displace[2]}
  774. local disp2 = {math.random(-60, 60), math.random(0, 25)}
  775.  
  776. local ld = 0
  777. while ld ~= 1 do
  778. local st = tick()
  779. r_serv.RenderStepped:wait()
  780. ld = math.min(1, ld + ((tick() - st) * 4))
  781. local eff = easein(ld)
  782.  
  783. local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  784. local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  785. horse_displace = {x, y}
  786. horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  787. end
  788. end
  789. end))
  790. end
  791.  
  792. --EASTER EGG
  793.  
  794. local last_va = 0
  795. local last_va2 = 0
  796. local view_velocity = {0, 0}
  797.  
  798. coroutine.resume(coroutine.create(function()
  799. local last_time = tick()
  800. while weld1.Parent ~= nil do
  801. r_serv.RenderStepped:wait() ------------------------------------------------
  802. local delta = tick() - last_time
  803. last_time = tick()
  804.  
  805. local breathe_amp = 2
  806. local breathe_freq = 0.8
  807. local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  808.  
  809. local shake_freq = 5
  810. local shake_amp = {0.05, 0.05}
  811. local arm_shake = CFrame.new(
  812. math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  813. 0,
  814. math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  815.  
  816.  
  817. --ANIMATION LOOP
  818. local p_distance = (head.Position - mouse.Hit.p).magnitude
  819. if p_distance == 0 then p_distance = 0.0001 end
  820. local p_height = mouse.Hit.p.y - head.Position.y
  821. local view_angle
  822. if p_height ~= 0 then
  823. view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  824. else
  825. view_angle = 0
  826. end
  827.  
  828. local cam_cf = camera.CoordinateFrame
  829. local looking_at = cam_cf * CFrame.new(0, 0, -100)
  830. local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  831.  
  832. local v_delta1, v_delta2
  833. local dir1 = 0
  834. local dir2 = 0
  835. v_delta1 = math.abs(view_angle - last_va)
  836. if v_delta1 ~= 0 then
  837. dir1 = (view_angle - last_va) / v_delta1
  838. end
  839. local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  840. if view_angle2 == last_va2 then
  841. dir2 = 0
  842. v_delta2 = 0
  843. elseif va_check[1] < va_check[2] then
  844. v_delta2 = va_check[1]
  845. dir2 = (view_angle2 - last_va2) / va_check[1]
  846. else
  847. v_delta2 = va_check[2]
  848. if last_va2 > view_angle2 then
  849. dir2 = 1
  850. else
  851. dir2 = -1
  852. end
  853. end
  854. last_va = view_angle
  855. last_va2 = view_angle2
  856.  
  857. view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  858. view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  859.  
  860. local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  861. if calc1 ~= 0 then
  862. view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  863. end
  864. local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  865. if calc2 ~= 0 then
  866. view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  867. end
  868.  
  869. if view_velocity[1] ~= 0 then
  870. view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  871. end
  872. if view_velocity[2] ~= 0 then
  873. view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  874. end
  875.  
  876. local anmtp = _G.MurderKnife_AnimType
  877. local anmst = _G.MurderKnife_AnimState
  878.  
  879. if anmst == nil then
  880. anmst = 0
  881. end
  882.  
  883. if anmtp ~= nil then
  884. if Animations[anmtp] == nil then
  885. anmtp = "Default"
  886. end
  887. else
  888. anmtp = "Default"
  889. end
  890. local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  891.  
  892. --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  893.  
  894. local chestCF = CFrame.new(0, 0.5, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_chest, math.min(rot_amplitude_chest, view_angle)) + 90 + breathe), 0, 0)
  895. weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  896. weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  897. wep_weld.C1 = (curr_anim[3]):inverse()
  898. weapon_parts[1].Transparency = curr_anim[4]
  899. if anim_head then
  900. weld3.C1 = (CFrame.new(0, 0, 0) * CFrame.Angles(math.rad(math.max(-rot_amplitude_head, math.min(rot_amplitude_head, view_angle))), 0, 0) * horse_cf):inverse()
  901. else
  902. weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  903. end
  904.  
  905. if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  906. if anim_model.Parent == nil then
  907. anim_model.Parent = camera
  908. end
  909. cam_welds[1].Parent = cam_larm
  910. cam_welds[2].Parent = cam_rarm
  911. cam_welds[3].Parent = weapon_parts[2]
  912. local cam_cf = camera.CoordinateFrame * CFrame.Angles(math.rad(90 + (breathe / 2) - view_velocity[1]), 0, math.rad(view_velocity[2])) * arm_shake * anim_p.cam_offset
  913. cam_welds[1].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(-1.5, 0, 0) * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  914. cam_welds[2].C1 = (torso.CFrame:inverse() * cam_cf * CFrame.new(1.5, 0, 0) * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  915. cam_welds[3].C1 = (curr_anim[3]):inverse()
  916. weapon_parts[2].Transparency = curr_anim[4]
  917. else
  918. if anim_model.Parent ~= nil then
  919. anim_model.Parent = nil
  920. end
  921. end
  922. --ANIMATION LOOP
  923. end
  924. end))
  925. end
  926.  
  927. local last_st = 0
  928. local eq = false
  929. tool.Selected:connect(function(mouse)
  930. if eq then return end
  931. eq = true
  932. wait()
  933. StartAnimation()
  934. end)
  935.  
  936. tool.Deselected:connect(function()
  937. eq = false
  938. EndAnimation()
  939. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement