Advertisement
MajourScripters

The Mad Murderer Knife

Mar 19th, 2016
3,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 36.29 KB | None | 0 0
  1. local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack)
  2. tool.Name="Knife"
  3.  
  4. wait()
  5. script.Parent=tool
  6.  
  7. --Murderer knife action script, original code from The Mad Murderer, by loleris.
  8.  
  9. wait()
  10. local camera = game.Workspace.CurrentCamera
  11. local player = game.Players.LocalPlayer
  12. local character = player.Character
  13. local humanoid = character.Humanoid
  14. local head = character.Head
  15. local torso = character.Torso
  16. local Left_Arm = character["Left Arm"]
  17. local Right_Arm = character["Right Arm"]
  18. local tool = script.Parent
  19. local pl_mouse = player:GetMouse()
  20.  
  21. local rs = game:GetService("RunService")
  22.  
  23. local stab_damage = 110
  24. local walkspeeds = {16, 19}
  25.  
  26. Settings = {
  27.     Equip_time = 0.1,
  28.     Idle_speed = 8,
  29.     Attack_speed = 0.6,
  30.     Throw_Offset = CFrame.new(1.5, 2, -0.3),
  31.     ThrowChargeDelay = 0.2,
  32.     DefaultKnifeSkin = "Default",
  33.     DefaultAbility = "Default",
  34.    
  35.     Crosshair = "rbxassetid://54019936",
  36. }
  37.  
  38. local KnifeSettings = {
  39.     Equip_time = 0.5,
  40.     Charge_time = 1,
  41.     Throw_speed = 2,
  42.    
  43.     ThrowDamage = 110,
  44.     SlashDamage = 110,
  45.    
  46.     CanThrow = true,
  47.     CanSlash = true,
  48. }
  49.  
  50. function GetIgnoreList(checkignored)
  51.     local result = {}
  52.     local ignored = false
  53.     if player.Character then
  54.         for _,c in pairs(player.Character:GetChildren()) do
  55.             if c:IsA("Part") then
  56.                 table.insert(result,c)
  57.                 if checkignored ~= nil and checkignored == c then
  58.                     ignored = true
  59.                 end
  60.             elseif c:IsA("Hat") then
  61.                 table.insert(result,c.Handle)
  62.                 if checkignored ~= nil and checkignored == c or checkignored == c.Handle then
  63.                     ignored = true
  64.                 end
  65.             elseif c:IsA("Tool") then
  66.                 if c:FindFirstChild("Handle") then
  67.                     table.insert(result,c.Handle)
  68.                     if checkignored ~= nil and checkignored == c or checkignored == c.Handle then
  69.                         ignored = true
  70.                     end
  71.                 end
  72.             end
  73.         end
  74.     end
  75.     for _,c in pairs(workspace:GetChildren()) do
  76.         if c.Name == "WeaponObject" then
  77.             table.insert(result,c)
  78.             if checkignored ~= nil and checkignored == c then
  79.                 ignored = true
  80.             end
  81.         end
  82.     end
  83.     for _,c in pairs(camera:GetChildren()) do
  84.         table.insert(result,c)
  85.         if checkignored ~= nil and checkignored == c then
  86.             ignored = true
  87.         end
  88.     end
  89.     if checkignored == nil then
  90.     return result
  91.     else
  92.     return ignored
  93.     end
  94. end
  95.  
  96. local assetlink = "http://www.roblox.com/asset/?id="
  97. local hit_sounds = {"153647516", "153647519", "153647522", "153647526"}
  98. local death_sounds = {"146594640", "146594648", "146457047"}
  99.  
  100. local Sounds = {
  101.     Equip = {
  102.         "153647514",
  103.     },
  104.     Slash = {
  105.         "153647529",
  106.         "153647534",
  107.         "153647539",
  108.         "153647540",
  109.     },
  110.     Throw = {
  111.         "153647549",
  112.         "153647554",
  113.     },
  114.     KnifeHitSurface = {
  115.         "153647563",
  116.         "153647564",
  117.     },
  118.     Death={
  119.         "146594640",
  120.         "146457047",
  121.         "146594648",
  122.         },
  123.     HitPlayer={
  124.         "153647516",
  125.         "153647519",
  126.         "153647522",
  127.         "153647526",
  128.     },
  129. }
  130.  
  131. function HIT_HANDLE(hit, dmg, pos)
  132.     if hit == nil then return end
  133.     local h = hit.Parent:findFirstChild("Humanoid")
  134.     if h == nil then
  135.         h = hit.Parent.Parent:findFirstChild("Humanoid")
  136.     end
  137.     if h == nil then return end
  138.     if h.Health <= 0 then return end
  139.    
  140.     local head = h.Parent:findFirstChild("Head")
  141.     if head == nil then return end
  142.    
  143.     local sound_part = Instance.new("Part")
  144.     sound_part.formFactor = "Custom"
  145.     sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  146.     sound_part.Transparency = 1
  147.     sound_part.CanCollide = false
  148.     sound_part.Anchored = true
  149.     sound_part.CFrame = head.CFrame
  150.     sound_part.Parent = Workspace
  151.     local s_hit = Instance.new("Sound")
  152.     s_hit.Volume = 1
  153.     s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  154.     s_hit.Parent = sound_part
  155.     local s_die = Instance.new("Sound")
  156.     s_die.Volume = 1
  157.     s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  158.     s_die.Parent = sound_part
  159.    
  160.     s_hit:play()
  161.    
  162.     local c_tag = Instance.new("ObjectValue")
  163.     c_tag.Name = "creator"
  164.     c_tag.Value = player
  165.     c_tag.Parent = h
  166.     h:TakeDamage(stab_damage)
  167.    
  168.     if h.Health <= dmg then
  169.         s_die:play()
  170.     end
  171. end
  172.  
  173. function RayCast(pos1, pos2, dist, ign)
  174.     local ray = Ray.new(
  175.         pos1,
  176.         (pos2 - pos1).unit * math.abs(dist)
  177.     )
  178.     local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  179.     return hit, hpos
  180. end
  181.  
  182. local larm = character:findFirstChild("Left Arm")
  183. local rarm = character:findFirstChild("Right Arm")
  184. function Slash(del)
  185.     coroutine.resume(coroutine.create(function()
  186.         local hits = {}
  187.        
  188.         local start = tick()
  189.         local actv = true
  190.        
  191.         local function ishitted(obj)
  192.             for i = 1, #hits do
  193.                 if obj:IsDescendantOf(hits[i]) then
  194.                     return true
  195.                 end
  196.             end
  197.             return false
  198.         end
  199.        
  200.         local function hitp(hit)
  201.             if ishitted(hit) then return end
  202.             local h = hit.Parent:findFirstChild("Humanoid")
  203.             if h == nil then
  204.                 h = hit.Parent.Parent:findFirstChild("Humanoid")
  205.             end
  206.             if h == nil then return end
  207.             hits[#hits + 1] = h.Parent
  208.             HIT_HANDLE(hit, stab_damage)
  209.         end
  210.        
  211.         local con = {
  212.             larm.Touched:connect(hitp),
  213.             rarm.Touched:connect(hitp),
  214.         }
  215.        
  216.         while tick() - start <= Settings.Attack_speed do wait() end
  217.         actv = false
  218.         con[1]:disconnect()
  219.         con[2]:disconnect()
  220.     end))
  221. end
  222.  
  223. local dg_sounds = {
  224.     equip = {
  225.         "153647514"
  226.     },
  227.     hit = {
  228.         "153647516",
  229.         "153647519",
  230.         "153647522",
  231.         "153647526"
  232.     },
  233.     Slash = {
  234.         "153647529",
  235.         "153647534",
  236.         "153647539",
  237.         "153647540"
  238.     },
  239.     Throw = {
  240.         "153647549",
  241.         "153647554",
  242.     },
  243.     KnifeHitSurface = {
  244.         "153647563",
  245.         "153647564",
  246.     },
  247.     Death={
  248.         "146594640",
  249.         "146457047",
  250.         "146594648",
  251.     },
  252. }
  253.  
  254. local dg_soundobj = {}
  255. for k, v in pairs(dg_sounds) do
  256.     dg_soundobj[k] = {}
  257.     for i = 1, #v do
  258.         local ns = Instance.new("Sound")
  259.         ns.SoundId = assetlink .. v[i]
  260.         ns.Volume = 1
  261.         dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  262.     end
  263. end
  264.  
  265. function LoadSounds()
  266.     for __, v in pairs(dg_soundobj) do
  267.         for i = 1, #v do
  268.             v[i].Parent = head
  269.         end
  270.     end
  271. end
  272. function RemoveSounds()
  273.     for __, v in pairs(dg_soundobj) do
  274.         for i = 1, #v do
  275.             v[i].Parent = nil
  276.         end
  277.     end
  278. end
  279. function PlaySound(nm, dl)
  280.     if dl == nil then
  281.         dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  282.     else
  283.         coroutine.resume(coroutine.create(function()
  284.             wait(dl)
  285.             dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  286.         end))
  287.     end
  288. end
  289.  
  290. local ThrowProperties = {
  291.     spin = 3,
  292.     min_vel = 80,
  293.     max_vel = 450,
  294.     min_g = 11,
  295.     max_g = 17,
  296.     max_time = 30,
  297.     cleanup_time = 10,
  298.     fade_time = 1,
  299. }
  300.  
  301. function Throw(target, pw, throw_prop)
  302.     throw_prop = ThrowProperties --meh
  303.     coroutine.resume(coroutine.create(function()
  304.         local knf = Instance.new("Part")
  305.         knf.Name = "WeaponObject"
  306.         knf.CanCollide = false
  307.         knf.Anchored = true
  308.         knf.formFactor = "Custom"
  309.         knf.Size = Vector3.new(0.2, 0.2, 0.2)
  310.         knf.BrickColor = character.WeaponObject.BrickColor
  311.         knf.Transparency = character.WeaponObject.Transparency
  312.         knf.Reflectance = character.WeaponObject.Reflectance
  313.         knf.TopSurface = 0
  314.         knf.BottomSurface = 0
  315.         local m = Instance.new("SpecialMesh")
  316.         m.MeshId = "http://www.roblox.com/asset/?id=121944778"
  317.         m.TextureId = character.WeaponObject.Mesh.TextureId
  318.         m.Scale = Vector3.new(0.6, 0.6, 0.6)
  319.         m.Parent = knf
  320.        
  321.         local hit_sound = nil
  322.        
  323.         local hit_sound = Instance.new("Sound")
  324.         hit_sound.Volume = 1
  325.         hit_sound.Pitch = 1
  326.         if #Sounds.KnifeHitSurface > 0 then
  327.             local sel_sound = dg_sounds.KnifeHitSurface[math.random(1, #dg_sounds.KnifeHitSurface)]
  328.             if type(sel_sound) == "string" then
  329.                 hit_sound = Instance.new("Sound")
  330.                 hit_sound.Volume = 1
  331.                 hit_sound.Pitch = 1
  332.                 hit_sound.SoundId = assetlink..sel_sound
  333.                 hit_sound.Parent = knf
  334.             elseif type(sel_sound) == "table" then
  335.                 hit_sound = {}
  336.                 for _, snd in pairs(sel_sound) do
  337.                     local sound = Instance.new("Sound")
  338.                     sound.Volume = 1
  339.                     sound.Pitch = 1
  340.                     sound.SoundId = assetlink..snd
  341.                     sound.Parent = knf
  342.                     table.insert(hit_sound, sound)
  343.                 end
  344.             end
  345.         end
  346.        
  347.         local start_pos = character.WeaponObject.Position
  348.         local trg_cf = CFrame.new(start_pos, target)
  349.         local dir_vec = (trg_cf).p - (trg_cf * CFrame.new(0, 0, -1)).p
  350.         local t_ang = math.abs(math.atan(math.abs(dir_vec.y / Vector2.new(dir_vec.x, dir_vec.z).magnitude)))
  351.         local isneg = -dir_vec.y / math.abs(dir_vec.y)
  352.        
  353.         local base_cf = CFrame.new(start_pos, Vector3.new(target.x, start_pos.y, target.z))
  354.         local curr_vel = throw_prop.min_vel + ((throw_prop.max_vel - throw_prop.min_vel) * pw)
  355.        
  356.         local curr_g = throw_prop.min_g + ((throw_prop.max_g - throw_prop.min_g) * (1 - pw))
  357.         local v_h = curr_vel * math.cos(t_ang)
  358.         local v_v = curr_vel * math.sin(t_ang) * isneg
  359.        
  360.         local function GetCf(t)
  361.             return base_cf * CFrame.new(0, v_v * t - (curr_g * (t ^2) * 0.5), -v_h * t)
  362.         end
  363.         local function throw_rc(p1, p2)
  364.             return RayCast(p1, p2, (p1 - p2).magnitude + 0.001, GetIgnoreList())
  365.         end
  366.        
  367.         knf.Parent = workspace
  368.         knf.CFrame = base_cf
  369.        
  370.         local hit, pos
  371.        
  372.         spawn(function()
  373.             local flying = true
  374.             local start = tick()
  375.             local last_p = base_cf.p
  376.             while flying and tick() - start < throw_prop.max_time do
  377.                 local new_ps = GetCf(tick() - start)
  378.                 knf.CFrame = new_ps * CFrame.Angles(math.rad(-360 * (tick() * throw_prop.spin - math.floor(tick() * throw_prop.spin))), 0, 0)
  379.                 local ht, ps = throw_rc(last_p, new_ps.p)
  380.                 if ht ~= nil and ht~=knf then
  381.                     hit = ht
  382.                     print(hit.className .. " " .. hit.Name .. " :: " .. hit.Parent.Name)
  383.                     pos = ps
  384.                     break
  385.                 end
  386.                 if humanoid.Health <= 0 then
  387.                     knf:remove()
  388.                     return
  389.                 end
  390.                 last_p = new_ps.p
  391.                 rs.RenderStepped:wait()
  392.             end
  393.            
  394.             if hit == nil then
  395.                 knf:remove()
  396.             else
  397.                 if not hit.Anchored then
  398.                     knf:remove()
  399.                 else
  400.                     knf.CFrame = CFrame.new(last_p, pos) * CFrame.new(0, 0, 0.4-(last_p - pos).magnitude) * CFrame.Angles(math.rad(-90), 0, 0)
  401.                     if hit_sound ~= nil then
  402.                         if type(hit_sound) == "table" then
  403.                             for _, snd_obj in pairs(hit_sound) do
  404.                                 snd_obj:Play()
  405.                             end
  406.                         else
  407.                             hit_sound:Play()
  408.                         end
  409.                     end
  410.                 end
  411.    
  412.                 if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") and hit.Parent.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
  413.                     if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
  414.                         HIT_HANDLE(hit, KnifeSettings.ThrowDamage, {"Throw"})
  415.                     else
  416.                         HIT_HANDLE(hit.Parent, KnifeSettings.ThrowDamage, {"Throw"})
  417.                     end
  418.                 end
  419.             end
  420.         end)
  421.     end))
  422. end
  423.  
  424. local function OnThrow(target, power) --Called when the knife is thrown
  425.     Throw(target, power, ThrowProperties)
  426. end
  427.  
  428. local function SlashHandle(hit) --Called when the knife is slashed
  429.     if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
  430.         if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid"):IsA("Humanoid") then
  431.             HIT_HANDLE(hit, KnifeSettings.ThrowDamage, {"Slash"})
  432.         else
  433.             HIT_HANDLE(hit.Parent, KnifeSettings.ThrowDamage, {"Slash"})
  434.         end
  435.         return hit.Parent
  436.     end
  437.     return nil
  438.     --return object to add to ignore list
  439. end
  440.  
  441. _G.MurderKnife_AnimType = "Default"
  442. _G.MurderKnife_AnimState = 0
  443.  
  444. function Animate(tp, st)
  445.     _G.MurderKnife_AnimType = tp
  446.     _G.MurderKnife_AnimState = st
  447. end
  448.  
  449. function SLASH()
  450.     coroutine.resume(coroutine.create(function()
  451.         local hits = {}
  452.        
  453.         local start = tick()
  454.         local actv = true
  455.        
  456.         local function ishitted(obj)
  457.             for i = 1, #hits do
  458.                 if obj:IsDescendantOf(hits[i]) then
  459.                     return true
  460.                 end
  461.             end
  462.             return false
  463.         end
  464.        
  465.         local function hitp(hit)
  466.             if ishitted(hit) then return end
  467.             if hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("Humanoid") then
  468.                 hit.Parent:BreakJoints()
  469.             end
  470.         end
  471.        
  472.         local con = {
  473.             Left_Arm.Touched:connect(hitp),
  474.             Right_Arm.Touched:connect(hitp),
  475.         }
  476.        
  477.         while tick() - start <= Settings.Attack_speed do wait() end
  478.         actv = false
  479.         con[1]:disconnect()
  480.         con[2]:disconnect()
  481.     end))
  482. end
  483.  
  484. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2, Attack3, Charge, Throw
  485.     humanoid.WalkSpeed = walkspeeds[2]
  486.     mouse.Icon = assetlink .. "54019936"
  487.     Animate("Charge", 0)
  488.     LoadSounds()
  489.     PlaySound("equip", 0.1)
  490.    
  491.     local anim_equip = 1
  492.     local last_action = tick()
  493.     local idle_rand = math.random(4, 7)
  494.     local idle_perform = 0
  495.     local idle_type = 1
  496.    
  497.     local attack_perform = 0
  498.     local attack_type = 1
  499.    
  500.     local running = true
  501.     local last_c = tick()
  502.     local mouse_holding = false
  503.     local throw_charge = 0
  504.     local throw_perform = 0
  505.    
  506.     local function StartSlash()
  507.         if tick() - attack_perform <= Settings.Attack_speed or tick() - throw_perform <= KnifeSettings.Throw_speed or anim_equip > 0 then return end
  508.         attack_perform = tick()
  509.         last_action = tick()
  510.         attack_type = math.random(1, 3)
  511.         idle_perform = 0
  512.         SLASH()
  513.         PlaySound("Slash", 0.23 * Settings.Attack_speed)
  514.     end
  515.    
  516.     local click_start = tick()
  517.     mouse.Button1Down:connect(function()
  518.         mouse_holding = true
  519.         if not running or anim_equip > 0 or (tick() - throw_perform) < KnifeSettings.Throw_speed then return end
  520.         if KnifeSettings.CanThrow and KnifeSettings.CanSlash then --Throw and slash enabled
  521.             if tick() - attack_perform <= Settings.Attack_speed or tick() - throw_perform <= KnifeSettings.Throw_speed then return end
  522.             click_start = tick()
  523.         elseif KnifeSettings.CanThrow then --Throw only
  524.             if tick() - throw_perform <= KnifeSettings.Throw_speed then return end
  525.             click_start = tick()
  526.         elseif KnifeSettings.CanSlash then --Slash only
  527.             StartSlash()
  528.         end
  529.     end)
  530.    
  531.     mouse.Button1Up:connect(function()
  532.         mouse_holding = false
  533.         if not running or anim_equip > 0 or (tick() - throw_perform) < KnifeSettings.Throw_speed then return end
  534.         local clickd = tick() - click_start
  535.         click_start = math.huge
  536.         if KnifeSettings.CanThrow and KnifeSettings.CanSlash then --Throw and slash enabled
  537.             if clickd < Settings.ThrowChargeDelay then
  538.                 StartSlash()
  539.             else
  540.                 PlaySound("Throw")
  541.                 throw_perform = tick()
  542.                 OnThrow(mouse.Hit.p,math.min(clickd/KnifeSettings.Charge_time,1))
  543.                 delay(KnifeSettings.Throw_speed/2,function()
  544.                     PlaySound("equip", 0.1)
  545.                 end)
  546.                 delay(KnifeSettings.Throw_speed,function()
  547.                     if mouse_holding then
  548.                         click_start = tick()
  549.                     else
  550.                         click_start = math.huge
  551.                     end
  552.                 end)
  553.             end
  554.         elseif KnifeSettings.CanThrow then --Throw only
  555.             PlaySound("Throw")
  556.             throw_perform = tick()
  557.             OnThrow(mouse.Hit.p,math.min(clickd/KnifeSettings.Charge_time,1))
  558.             delay(KnifeSettings.Throw_speed/2,function()
  559.                 PlaySound("equip", 0.1)
  560.             end)
  561.             delay(KnifeSettings.Throw_speed,function()
  562.                 throw_perform = tick()
  563.             end)
  564.         elseif KnifeSettings.CanSlash then --Slash only
  565.         end
  566.     end)
  567.    
  568.     local conn = rs.RenderStepped:connect(function()
  569.         if not running then return end
  570.         local delta = tick() - last_c
  571.         last_c = tick()
  572.         local clickd = tick() - click_start
  573.        
  574.         if anim_equip > 0 then
  575.             anim_equip = math.max(0, anim_equip - (delta / KnifeSettings.Equip_time))
  576.             Animate("Equip", 1 - anim_equip)
  577.         elseif mouse_holding and clickd >= Settings.ThrowChargeDelay then
  578.             Animate("Charge", clickd/KnifeSettings.Charge_time)
  579.             idle_perform = 0
  580.         elseif tick() - throw_perform <= KnifeSettings.Throw_speed then
  581.             Animate("Throw", (tick() - throw_perform) / KnifeSettings.Throw_speed)
  582.             idle_perform = 0
  583.         elseif tick() - attack_perform <= Settings.Attack_speed then
  584.             Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  585.             idle_perform = 0
  586.         elseif tick() - idle_perform <= Settings.Idle_speed then
  587.             Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  588.         else
  589.             Animate("Default", 0)
  590.         end
  591.        
  592.         if tick() - last_action >= idle_rand then
  593.             idle_rand = math.random(12, 20)
  594.             last_action = tick()
  595.             idle_perform = tick()
  596.             idle_type = math.random(1, 2)
  597.         end
  598.        
  599.     end)
  600.     tool.Deselected:connect(function() running = false conn:disconnect() end)
  601. end)
  602. tool.Deselected:connect(function()
  603.     RemoveSounds()
  604.     humanoid.WalkSpeed = walkspeeds[1]
  605. end)
  606.  
  607. --Murderer knife animation module, original code from The Mad Murderer, by loleris.
  608.  
  609. local tool = script.Parent
  610. local player = game.Players.LocalPlayer
  611. local character = player.Character
  612. local humanoid = character:findFirstChild("Humanoid")
  613. local camera = Workspace.CurrentCamera
  614. local mouse = player:GetMouse()
  615.  
  616. local conn_type = "Snap"
  617.  
  618. local anim_head = false
  619.  
  620. weapon_properties = {
  621.     mesh_id = "http://www.roblox.com/asset/?id=121944778",
  622.     texture_id = "http://www.roblox.com/asset/?id=121944805", --ADD TEXTURE HERE------------------------------------------------
  623.     scale = Vector3.new(0.6, 0.6, 0.6),
  624.     transparency = 0,
  625.     reflectance = 0,
  626.     brick_color = BrickColor.new("Really black"),
  627. }
  628.  
  629. --How did I make all of this? Magic. Didn't even need an animation editor :)
  630. Animations = {
  631.     Default = {
  632.         {{}, 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)}
  633.     },
  634.     Equip = {
  635.         {{}, 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)},
  636.         {{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)},
  637.         {{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)},
  638.     },
  639.     Idle1 = {
  640.         {{}, 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)},
  641.         {{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)},
  642.         {{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)},
  643.         {{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)},
  644.     },
  645.     Idle2 = {
  646.         {{}, 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)},
  647.         {{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)},
  648.         {{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)},
  649.         {{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)},
  650.         {{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)}
  651.     },
  652.     Attack1 = {
  653.         {{}, 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)},
  654.         {{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)},
  655.         {{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)},
  656.         {{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)}
  657.     },
  658.     Attack2 = {
  659.         {{}, 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)},
  660.         {{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)},
  661.         {{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)},
  662.         {{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)}
  663.     },
  664.     Attack3 = {
  665.         {{}, 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)},
  666.         {{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)},
  667.         {{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)},
  668.         {{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.
  669.     },
  670.     Charge = {
  671.         {{}, 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)},
  672.         {{1, 2}, 0, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 1.047), CFrame.new(-0.201, 0, -0.201) * CFrame.Angles(1.396, 0.087, 0.174), CFrame.new(0, -0.801, -0.801) * CFrame.Angles(-1.222, 0, 0)}
  673.     },
  674.     Throw = {
  675.         {{}, 1, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.35, 0, 1.047), CFrame.new(-0.201, 0, -0.201) * CFrame.Angles(1.396, 0.087, 0.174), CFrame.new(0, -0.801, -0.801) * CFrame.Angles(-1.222, 0, 0)},
  676.         {{0.1, 2}, 1, CFrame.new(0.5, -0.301, 0.2) * CFrame.Angles(-0.873, 0, 0.523), CFrame.new(-0.201, -0.201, 0.1) * CFrame.Angles(-0.35, 0.087, -0.175), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  677.         {{0.5, 2}, 1, CFrame.new(0.5, -0.401, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.201, -0.201, 0) * CFrame.Angles(-1.92, -0.175, 0.174), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  678.         {{0, 2}, 0, CFrame.new(0.5, -0.401, 0.2) * CFrame.Angles(-0.699, 0, 0.872), CFrame.new(-0.201, -0.201, 0) * CFrame.Angles(-1.92, -0.175, 0.174), CFrame.new(0, -0.95, -0.801) * CFrame.Angles(-1.571, 0, 0)},
  679.         {{0.4, 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)}
  680.     }
  681. }
  682.  
  683.  
  684. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  685.     local Diff2 = GetCFrame2.p - GetCFrame1.p
  686.     local GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  687.     GetCFrame2 = GetCFrame2 - GetCFrame2.p
  688.     local Diff = GetCFrame1_s:inverse() * GetCFrame2
  689.     local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  690.     return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  691. end
  692.  
  693. function TransEff(x, type)
  694.     if type == 1 then
  695.         return x
  696.     elseif type == 2 then
  697.         return x*x*(3 - 2*x)
  698.     elseif type == 3 then
  699.         return math.sin(math.rad(x * 90))
  700.     elseif type == 4 then
  701.         return 1 - math.sin(math.rad((1 - x) * 90))
  702.     end
  703. end
  704.  
  705. function num_trans(n1, n2, x)
  706.     return n1 + ((n2 - n1) * x)
  707. end
  708.  
  709. function PlayAnimation(animd, tm) --return {left, right, wep, trans}
  710.     tm = math.min(1, math.max(0, tm))
  711.     local anim = Animations[animd]
  712.     if #anim == 1 then
  713.         return {anim[1][3], anim[1][4], anim[1][5], anim[1][2]}
  714.     else
  715.         local trans_from = 1
  716.         local trans_to = 1
  717.         local tm_left = tm
  718.         for i = 2, #anim do
  719.             tm_left = tm_left - anim[i][1][1]
  720.             if tm_left <= 0 then
  721.                 trans_from = i - 1
  722.                 trans_to = i
  723.                 break
  724.             end
  725.         end
  726.         local trans_amm = TransEff((anim[trans_to][1][1] + tm_left) / anim[trans_to][1][1], anim[trans_to][1][2])
  727.         return {
  728.             CFrameTrans(anim[trans_from][3], anim[trans_to][3], trans_amm),
  729.             CFrameTrans(anim[trans_from][4], anim[trans_to][4], trans_amm),
  730.             CFrameTrans(anim[trans_from][5], anim[trans_to][5], trans_amm),
  731.             num_trans(anim[trans_from][2], anim[trans_to][2], trans_amm)
  732.         }
  733.     end
  734. end
  735.  
  736. rot_amplitude_head = 20
  737. rot_amplitude_chest = 15
  738.  
  739. anim_p = {
  740.     cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  741.     aim_amp = 0.5,
  742.     aim_max_change = 4,
  743.     aim_retract = 15,
  744.     aim_max_deg = 20,
  745. }
  746.  
  747. local weapon_model = Instance.new("Part")
  748. weapon_model.CanCollide = false
  749. weapon_model.Name = "WeaponObject"
  750. weapon_model.formFactor = "Custom"
  751. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  752. weapon_model.TopSurface = 0
  753. weapon_model.BottomSurface = 0
  754. weapon_model.BrickColor = weapon_properties.brick_color
  755. weapon_model.Transparency = weapon_properties.transparency
  756. weapon_model.Reflectance = weapon_properties.reflectance
  757. local mesh = Instance.new("SpecialMesh", weapon_model)
  758. mesh.Scale = weapon_properties.scale
  759. mesh.MeshId = weapon_properties.mesh_id
  760. mesh.TextureId = weapon_properties.texture_id
  761.  
  762. torso = character.Torso
  763. head = character.Head
  764.  
  765. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  766. welds = {nil, nil, nil}
  767. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  768. weapon_model = nil
  769.  
  770. function EndAnimation()
  771.     if motors[1] then
  772.         motors[1].Part1 = character:findFirstChild("Left Arm")
  773.     end
  774.     if motors[2] then
  775.         motors[2].Part1 = character:findFirstChild("Right Arm")
  776.     end
  777.     if motors[3] then
  778.         motors[3].Part1 = character:findFirstChild("Head")
  779.     end
  780.     if welds[1] then
  781.         welds[1]:remove()
  782.         welds[1] = nil
  783.     end
  784.     if welds[2] then
  785.         welds[2]:remove()
  786.         welds[2] = nil
  787.     end
  788.     if welds[3] then
  789.         welds[3]:remove()
  790.         welds[3] = nil
  791.     end
  792.     weapon_parts[1].Parent = nil
  793.     if weapon_model then
  794.         weapon_model.Parent = nil
  795.     end
  796.     coroutine.resume(coroutine.create(function()
  797.         local swm = weapon_model
  798.         wait()
  799.         swm.Parent = nil
  800.         wait(0.1)
  801.         swm.Parent =  nil
  802.         wait(0.5)
  803.         swm.Parent =  nil
  804.     end))
  805. end
  806.  
  807. local anim_model = Instance.new("Model")
  808. anim_model.Name = "WeaponAnimation"
  809. weapon_model = anim_model
  810.    
  811. local cam_larm = Instance.new("Part")
  812. cam_larm.Parent = anim_model
  813. cam_larm.BrickColor = BrickColor.new("Really black")
  814. cam_larm.formFactor = "Custom"
  815. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  816. cam_larm.TopSurface = 0
  817. cam_larm.BottomSurface = 0
  818. cam_larm.Transparency = 0.4
  819. cam_larm.CanCollide = false
  820. local hmesh = Instance.new("BlockMesh", cam_larm)
  821. hmesh.Scale = Vector3.new(5, 10, 5)
  822.  
  823. local cam_rarm = cam_larm:clone()
  824. cam_rarm.Parent = anim_model
  825.  
  826. function StartAnimation()
  827.     local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  828.     if check[1] then check[1]:remove() end
  829.     if check[2] then check[2]:remove() end
  830.     if check[3] then check[3]:remove() end
  831.     local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  832.     if check2[1] then check2[1].Parent = nil end
  833.     if check2[2] then check2[2].Parent = nil end
  834.     if motors[1] then
  835.         motors[1].Part1 = nil
  836.     end
  837.     if motors[2] then
  838.         motors[2].Part1 = nil
  839.     end
  840.     if motors[3] then
  841.         motors[3].Part1 = nil
  842.     end
  843.     welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  844.     welds[1].Part0 = torso
  845.     welds[2].Part0 = torso
  846.     welds[3].Part0 = torso
  847.     welds[1].Part1 = character:findFirstChild("Left Arm")
  848.     welds[2].Part1 = character:findFirstChild("Right Arm")
  849.     welds[3].Part1 = character:findFirstChild("Head")
  850.     welds[1].Name = "LeftWeld"
  851.     welds[2].Name = "RightWeld"
  852.     welds[2].Name = "HeadWeld"
  853.     welds[1].C0 = CFrame.new(-1.5, 0, 0)
  854.     welds[2].C0 = CFrame.new(1.5, 0, 0)
  855.     welds[3].C0 = CFrame.new(0, 1.5, 0)
  856.     welds[1].Parent = torso
  857.     welds[2].Parent = torso
  858.     welds[3].Parent = torso
  859.    
  860.     weapon_parts[1].Parent = character
  861.     local wep_weld = Instance.new(conn_type)
  862.     wep_weld.Part0 = character:findFirstChild("Right Arm")
  863.     wep_weld.Part1 = weapon_parts[1]
  864.     wep_weld.C0 = CFrame.new()
  865.     wep_weld.Parent = weapon_parts[1]
  866.    
  867.     local weld1 = welds[1]
  868.     local weld2 = welds[2]
  869.     local weld3 = welds[3]
  870.    
  871.     local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  872.     cam_welds[1].Part0 = torso
  873.     cam_welds[1].Part1 = cam_larm
  874.     cam_welds[1].Parent = cam_larm
  875.     cam_welds[2].Part0 = torso
  876.     cam_welds[2].Part1 = cam_rarm
  877.     cam_welds[2].Parent = cam_rarm
  878.     cam_welds[3].Part0 = cam_rarm
  879.     cam_welds[3].Part1 = weapon_parts[2]
  880.     cam_welds[3].Parent = weapon_parts[2]
  881.     weapon_parts[2].Parent = anim_model
  882.    
  883.     local move_anim_speed = 3
  884.     local last_p = Vector3.new()
  885.     local move_amm = 0
  886.     coroutine.resume(coroutine.create(function()
  887.         while weld1.Parent ~= nil do
  888.             local delta = wait(1/25)
  889.             local cur_p = torso.Position
  890.             if (cur_p - last_p).magnitude >= 0.1 then
  891.                 move_amm = math.min(1, move_amm + delta * move_anim_speed)
  892.             else
  893.                 move_amm = math.max(0, move_amm - delta * move_anim_speed)
  894.             end
  895.             last_p = cur_p
  896.         end
  897.     end))
  898.    
  899.     local r_serv = game:GetService("RunService")
  900.    
  901.     --EASTER EGG
  902.     function easein(x)
  903.         return math.sin(math.rad(x * 90))
  904.     end
  905.  
  906.     local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  907.     local horse_displace = {0, 0}
  908.     local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  909.     if a_horse then
  910.         coroutine.resume(coroutine.create(function()
  911.             while weld1.Parent ~= nil do
  912.                 local rndwait = (math.random(100, 1000) / 1000) * 4
  913.                 wait(rndwait)
  914.                 local oldd = {horse_displace[1], horse_displace[2]}
  915.                 local disp2 = {math.random(-60, 60), math.random(0, 25)}
  916.                
  917.                 local ld = 0
  918.                 while ld ~= 1 do
  919.                     local st = tick()
  920.                     r_serv.RenderStepped:wait()
  921.                     ld = math.min(1, ld + ((tick() - st) * 4))
  922.                     local eff = easein(ld)
  923.                    
  924.                     local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  925.                     local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  926.                     horse_displace = {x, y}
  927.                     horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  928.                 end
  929.             end
  930.         end))
  931.     end
  932.    
  933.     --EASTER EGG
  934.    
  935.     local last_va = 0
  936.     local last_va2 = 0
  937.     local view_velocity = {0, 0}
  938.    
  939.     coroutine.resume(coroutine.create(function()
  940.         local last_time = tick()
  941.         while weld1.Parent ~= nil do
  942.             r_serv.RenderStepped:wait() ------------------------------------------------
  943.             local delta = tick() - last_time
  944.             last_time = tick()
  945.            
  946.             local breathe_amp = 2
  947.             local breathe_freq = 0.8
  948.             local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  949.            
  950.             local shake_freq = 5
  951.             local shake_amp = {0.05, 0.05}
  952.             local arm_shake = CFrame.new(
  953.                 math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  954.                 0,
  955.                 math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  956.  
  957.  
  958.             --ANIMATION LOOP
  959.             local p_distance = (head.Position - mouse.Hit.p).magnitude
  960.             if p_distance == 0 then p_distance = 0.0001 end
  961.             local p_height = mouse.Hit.p.y - head.Position.y
  962.             local view_angle
  963.             if p_height ~= 0 then
  964.                 view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  965.             else
  966.                 view_angle = 0
  967.             end
  968.            
  969.             local cam_cf = camera.CoordinateFrame
  970.             local looking_at = cam_cf * CFrame.new(0, 0, -100)
  971.             local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  972.            
  973.             local v_delta1, v_delta2
  974.             local dir1 = 0
  975.             local dir2 = 0
  976.             v_delta1 = math.abs(view_angle - last_va)
  977.             if v_delta1 ~= 0 then
  978.                 dir1 = (view_angle - last_va) / v_delta1
  979.             end
  980.             local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  981.             if view_angle2 == last_va2 then
  982.                 dir2 = 0
  983.                 v_delta2 = 0
  984.             elseif va_check[1] < va_check[2] then
  985.                 v_delta2 = va_check[1]
  986.                 dir2 = (view_angle2 - last_va2) / va_check[1]
  987.             else
  988.                 v_delta2 = va_check[2]
  989.                 if last_va2 > view_angle2 then
  990.                     dir2 = 1
  991.                 else
  992.                     dir2 = -1
  993.                 end
  994.             end
  995.             last_va = view_angle
  996.             last_va2 = view_angle2
  997.            
  998.             view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  999.             view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  1000.            
  1001.             local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  1002.             if calc1 ~= 0 then
  1003.                 view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  1004.             end
  1005.             local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  1006.             if calc2 ~= 0 then
  1007.                 view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  1008.             end
  1009.            
  1010.             if view_velocity[1] ~= 0 then
  1011.                 view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  1012.             end
  1013.             if view_velocity[2] ~= 0 then
  1014.                 view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  1015.             end
  1016.            
  1017.             local anmtp = _G.MurderKnife_AnimType
  1018.             local anmst = _G.MurderKnife_AnimState
  1019.            
  1020.             if anmst == nil then
  1021.                 anmst = 0
  1022.             end
  1023.            
  1024.             if anmtp ~= nil then
  1025.                 if Animations[anmtp] == nil then
  1026.                     anmtp = "Default"
  1027.                 end
  1028.             else
  1029.                 anmtp = "Default"
  1030.             end
  1031.             local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  1032.            
  1033.             --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  1034.            
  1035.             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)
  1036.             weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  1037.             weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  1038.             wep_weld.C1 = (curr_anim[3]):inverse()
  1039.             weapon_parts[1].Transparency = curr_anim[4]
  1040.             if anim_head then
  1041.                 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()
  1042.             else
  1043.                 weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  1044.             end
  1045.            
  1046.             if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  1047.                 if anim_model.Parent == nil then
  1048.                     anim_model.Parent = camera
  1049.                 end
  1050.                 cam_welds[1].Parent = cam_larm
  1051.                 cam_welds[2].Parent = cam_rarm
  1052.                 cam_welds[3].Parent = weapon_parts[2]
  1053.                 for _,c in pairs(cam_larm:GetChildren()) do
  1054.                     if c:IsA("Snap") and c ~= cam_welds[1] then
  1055.                         c:remove()
  1056.                     end
  1057.                 end
  1058.                 for _,c in pairs(cam_rarm:GetChildren()) do
  1059.                     if c:IsA("Snap") and c ~= cam_welds[2] then
  1060.                         c:remove()
  1061.                     end
  1062.                 end
  1063.                 for _,c in pairs(weapon_parts[2]:GetChildren()) do
  1064.                     if c:IsA("Snap") and c ~= cam_welds[3] then
  1065.                         c:remove()
  1066.                     end
  1067.                 end
  1068.                 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
  1069.                 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()
  1070.                 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()
  1071.                 cam_welds[3].C1 = (curr_anim[3]):inverse()
  1072.                 weapon_parts[2].Transparency = curr_anim[4]
  1073.             else
  1074.                 if anim_model.Parent ~= nil then
  1075.                     anim_model.Parent = nil
  1076.                 end
  1077.             end
  1078.             --ANIMATION LOOP
  1079.         end
  1080.     end))
  1081. end
  1082.  
  1083. local last_st = 0
  1084. local eq = false
  1085. tool.Selected:connect(function(mouse)
  1086.     if eq then return end
  1087.     eq = true
  1088.     wait()
  1089.     StartAnimation()
  1090. end)
  1091.  
  1092. tool.Deselected:connect(function()
  1093.     eq = false
  1094.     EndAnimation()
  1095. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement