Advertisement
Gememed

Ban hammer

Jun 4th, 2019
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --https://github.com/Mokiros/roblox-FE-compatibility
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,game,owner = owner,game
  5. local RealPlayer = Player
  6. do
  7.     print("FE Compatibility code V2 by Mokiros")
  8.     local RealPlayer = RealPlayer
  9.     script.Parent = RealPlayer.Character
  10.  
  11.     --Fake event to make stuff like Mouse.KeyDown work
  12.     local Disconnect_Function = function(this)
  13.         this[1].Functions[this[2]] = nil
  14.     end
  15.     local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  16.     local FakeEvent_Metatable = {__index={
  17.         Connect = function(this,f)
  18.             local i = tostring(math.random(0,10000))
  19.             while this.Functions[i] do
  20.                 i = tostring(math.random(0,10000))
  21.             end
  22.             this.Functions[i] = f
  23.             return setmetatable({this,i},Disconnect_Metatable)
  24.         end
  25.     }}
  26.     FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  27.     local function fakeEvent()
  28.         return setmetatable({Functions={}},FakeEvent_Metatable)
  29.     end
  30.  
  31.     --Creating fake input objects with fake variables
  32.     local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  33.     FakeMouse.keyUp = FakeMouse.KeyUp
  34.     FakeMouse.keyDown = FakeMouse.KeyDown
  35.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  36.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  37.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  38.     end}
  39.     --Merged 2 functions into one by checking amount of arguments
  40.     CAS.UnbindAction = CAS.BindAction
  41.  
  42.     --This function will trigger the events that have been :Connect()'ed
  43.     local function TriggerEvent(self,ev,...)
  44.         for _,f in pairs(self[ev].Functions) do
  45.             f(...)
  46.         end
  47.     end
  48.     FakeMouse.TriggerEvent = TriggerEvent
  49.     UIS.TriggerEvent = TriggerEvent
  50.  
  51.     --Client communication
  52.     local Event = Instance.new("RemoteEvent")
  53.     Event.Name = "UserInput_Event"
  54.     Event.OnServerEvent:Connect(function(plr,io)
  55.         if plr~=RealPlayer then return end
  56.         FakeMouse.Target = io.Target
  57.         FakeMouse.Hit = io.Hit
  58.         if not io.isMouse then
  59.             local b = io.UserInputState == Enum.UserInputState.Begin
  60.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  61.                 return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  62.             end
  63.             if io.UserInputType == Enum.UserInputType.MouseButton2 then
  64.                 return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  65.             end
  66.             for _,t in pairs(CAS.Actions) do
  67.                 for _,k in pairs(t.Keys) do
  68.                     if k==io.KeyCode then
  69.                         t.Function(t.Name,io.UserInputState,io)
  70.                     end
  71.                 end
  72.             end
  73.             FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  74.             UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  75.         end
  76.     end)
  77.     Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  78.     local Mouse = owner:GetMouse()
  79.     local UIS = game:GetService("UserInputService")
  80.     local input = function(io,RobloxHandled)
  81.         if RobloxHandled then return end
  82.         --Since InputObject is a client-side instance, we create and pass table instead
  83.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  84.     end
  85.     UIS.InputBegan:Connect(input)
  86.     UIS.InputEnded:Connect(input)
  87.     local h,t
  88.     --Give the server mouse data every second frame, but only if the values changed
  89.     --If player is not moving their mouse, client won't fire events
  90.     local HB = game:GetService("RunService").Heartbeat
  91.     while true do
  92.         if h~=Mouse.Hit or t~=Mouse.Target then
  93.             h,t=Mouse.Hit,Mouse.Target
  94.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  95.         end
  96.         --Wait 2 frames
  97.         for i=1,2 do
  98.             HB:Wait()
  99.         end
  100.     end]==],script)
  101.  
  102.     ----Sandboxed game object that allows the usage of client-side methods and services
  103.     --Real game object
  104.     local RealGame = game
  105.  
  106.     --Metatable for fake service
  107.     local FakeService_Metatable = {
  108.         __index = function(self,k)
  109.             local s = rawget(self,"_RealService")
  110.             if s then
  111.                 return typeof(s[k])=="function"
  112.                 and function(_,...)return s[k](s,...)end or s[k]
  113.             end
  114.         end,
  115.         __newindex = function(self,k,v)
  116.             local s = rawget(self,"_RealService")
  117.             if s then s[k]=v end
  118.         end
  119.     }
  120.     local function FakeService(t,RealService)
  121.         t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  122.         return setmetatable(t,FakeService_Metatable)
  123.     end
  124.  
  125.     --Fake game object
  126.     local FakeGame = {
  127.         GetService = function(self,s)
  128.             return rawget(self,s) or RealGame:GetService(s)
  129.         end,
  130.         Players = FakeService({
  131.             LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  132.         },"Players"),
  133.         UserInputService = FakeService(UIS,"UserInputService"),
  134.         ContextActionService = FakeService(CAS,"ContextActionService"),
  135.         RunService = FakeService({
  136.             _btrs = {},
  137.             RenderStepped = RealGame:GetService("RunService").Heartbeat,
  138.             BindToRenderStep = function(self,name,_,fun)
  139.                 self._btrs[name] = self.Heartbeat:Connect(fun)
  140.             end,
  141.             UnbindFromRenderStep = function(self,name)
  142.                 self._btrs[name]:Disconnect()
  143.             end,
  144.         },"RunService")
  145.     }
  146.     rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  147.     FakeGame.service = FakeGame.GetService
  148.     FakeService(FakeGame,game)
  149.     --Changing owner to fake player object to support owner:GetMouse()
  150.     game,owner = FakeGame,FakeGame.Players.LocalPlayer
  151. end
  152. game.Players.LocalPlayer.Character.Humanoid.MaxHealth = 999999e999999
  153. local tool=Instance.new("HopperBin", game.Players.LocalPlayer.Backpack)
  154. tool.Name="SJ's Ultimate Ban Hammer"
  155.  
  156. wait()
  157. script.Parent=tool
  158.  
  159. --Murderer knife action script, original code from The Mad Murderer, by loleris.
  160.  
  161. wait()
  162. local camera = game.Workspace.CurrentCamera
  163. local player = game.Players.LocalPlayer
  164. local character = player.Character
  165. local humanoid = character.Humanoid
  166. local head = character.Head
  167. local torso = character.Torso
  168. local pl_mouse = player:GetMouse()
  169.  
  170. local rs = game:GetService("RunService")
  171.  
  172. local stab_damage = 9999999e9999999
  173. local walkspeeds = {80, 80}
  174.  
  175. Settings = {
  176.     Equip_time = 0.1,
  177.     Idle_speed = 0.1,
  178.     Attack_speed = 0.1,
  179. }
  180.  
  181. local assetlink = "http://www.roblox.com/asset/?id="
  182. local hit_sounds = {"501642310", "501642310", "501642310", "501642310"}
  183. local death_sounds = {"501642310", "501642310", "501642310"}
  184. function Clean(obj)
  185.     spawn(function()
  186.         wait(6)
  187.         obj:remove()
  188.     end)
  189. end
  190.  
  191. function HIT_HANDLE(hit, dmg, pos)
  192.     if hit == nil then return end
  193.     local h = hit.Parent:findFirstChild("Humanoid")
  194.     if h == nil then
  195.         h = hit.Parent.Parent:findFirstChild("Humanoid")
  196.     end
  197.     if h == nil then return end
  198.     if h.Health <= 0 then return end
  199.    
  200.     local head = h.Parent:findFirstChild("Head")
  201.     if head == nil then return end
  202.    
  203.     local sound_part = Instance.new("Part")
  204.     sound_part.formFactor = "Custom"
  205.     sound_part.Size = Vector3.new(0.2, 0.2, 0.2)
  206.     sound_part.Transparency = 1
  207.     sound_part.CanCollide = false
  208.     sound_part.Anchored = true
  209.     sound_part.CFrame = head.CFrame
  210.     Clean(sound_part)
  211.     sound_part.Parent = Workspace
  212.     local s_hit = Instance.new("Sound")
  213.     s_hit.Volume = 1
  214.     s_hit.SoundId = assetlink .. hit_sounds[math.random(1, #hit_sounds)]
  215.     s_hit.Parent = sound_part
  216.     local s_die = Instance.new("Sound")
  217.     s_die.Volume = 1
  218.     s_die.SoundId = assetlink .. death_sounds[math.random(1, #death_sounds)]
  219.     s_die.Parent = sound_part
  220.    
  221.     s_hit:play()
  222.    
  223.     local c_tag = Instance.new("ObjectValue")
  224.     c_tag.Name = "creator"
  225.     c_tag.Value = player
  226.     c_tag.Parent = h
  227.     h.Health=0
  228.     s_die:play()
  229. end
  230.  
  231. function GENERATE_IGNORELIST()
  232.     local result = {character, camera}
  233.     local plr = game.Players:GetPlayers()
  234.     for i = 1, #plr do
  235.         if plr[i] ~= player then
  236.             local char = plr[i].Character
  237.             if char ~= nil then
  238.                 local ch = char:GetChildren()
  239.                 for i = 1, #ch do
  240.                     if ch[i]:IsA("Hat") or ch[i]:IsA("Tool") then
  241.                         result[#result + 1] = ch[i]
  242.                     end
  243.                 end
  244.             end
  245.         end
  246.     end
  247.     return result
  248. end
  249.  
  250. function RayCast(pos1, pos2, dist, ign)
  251.     local ray = Ray.new(
  252.         pos1,
  253.         (pos2 - pos1).unit * math.abs(dist)
  254.     )
  255.     local hit, hpos = Workspace:FindPartOnRayWithIgnoreList(ray, ign, false)
  256.     return hit, hpos
  257. end
  258.  
  259. local larm = character:findFirstChild("Left Arm")
  260. local rarm = character:findFirstChild("Right Arm")
  261. function Slash(del)
  262.     coroutine.resume(coroutine.create(function()
  263.         local hits = {}
  264.        
  265.         local start = tick()
  266.         local actv = true
  267.        
  268.         local function ishitted(obj)
  269.             for i = 1, #hits do
  270.                 if obj:IsDescendantOf(hits[i]) then
  271.                     return true
  272.                 end
  273.             end
  274.             return false
  275.         end
  276.        
  277.         local function hitp(hit)
  278.             if ishitted(hit) then return end
  279.             local h = hit.Parent:findFirstChild("Humanoid")
  280.             if h == nil then
  281.                 h = hit.Parent.Parent:findFirstChild("Humanoid")
  282.             end
  283.             if h == nil then return end
  284.             hits[#hits + 1] = h.Parent
  285.             HIT_HANDLE(hit, stab_damage)
  286.         end
  287.        
  288.         local con = {
  289.             larm.Touched:connect(hitp),
  290.             rarm.Touched:connect(hitp),
  291.         }
  292.        
  293.         while tick() - start <= Settings.Attack_speed do wait() end
  294.         actv = false
  295.         con[1]:disconnect()
  296.         con[2]:disconnect()
  297.     end))
  298. end
  299.  
  300. local dg_sounds = {
  301.     equip = {
  302.         "465591978"
  303.     },
  304.     hit = {
  305.         "501642310",
  306.         "501642310",
  307.         "501642310",
  308.         "501642310"
  309.     },
  310.     swing = {
  311.         "528494638",
  312.         "528494638",
  313.         "528494638",
  314.         "528494638"
  315.     }
  316. }
  317.  
  318. local dg_soundobj = {}
  319. for k, v in pairs(dg_sounds) do
  320.     dg_soundobj[k] = {}
  321.     for i = 1, #v do
  322.         local ns = Instance.new("Sound")
  323.         ns.SoundId = assetlink .. v[i]
  324.         ns.Volume = 1
  325.         dg_soundobj[k][#dg_soundobj[k] + 1] = ns
  326.     end
  327. end
  328.  
  329. function LoadSounds()
  330.     for __, v in pairs(dg_soundobj) do
  331.         for i = 1, #v do
  332.             v[i].Parent = head
  333.         end
  334.     end
  335. end
  336. function RemoveSounds()
  337.     for __, v in pairs(dg_soundobj) do
  338.         for i = 1, #v do
  339.             v[i].Parent = nil
  340.         end
  341.     end
  342. end
  343. function PlaySound(nm, dl)
  344.     if dl == nil then
  345.         dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  346.     else
  347.         coroutine.resume(coroutine.create(function()
  348.             wait(dl)
  349.             dg_soundobj[nm][math.random(1, #dg_soundobj[nm])]:play()
  350.         end))
  351.     end
  352. end
  353.  
  354. _G.MurderKnife_AnimType = "Default"
  355. _G.MurderKnife_AnimState = 0
  356.  
  357. function Animate(tp, st)
  358.     _G.MurderKnife_AnimType = tp
  359.     _G.MurderKnife_AnimState = st
  360. end
  361.  
  362. tool.Selected:connect(function(mouse) --Default, Idle1, Idle2, Attack1, Attack2
  363.     humanoid.WalkSpeed = walkspeeds[2]
  364.     mouse.Icon = assetlink .. "54019936"
  365.     Animate("Equip", 0)
  366.     LoadSounds()
  367.     PlaySound("equip", 0.1)
  368.    
  369.     local anim_equip = 1
  370.     local last_action = tick()
  371.     local idle_rand = math.random(4, 7)
  372.     local idle_perform = 0
  373.     local idle_type = 1
  374.    
  375.     local attack_perform = 0
  376.     local attack_type = 1
  377.    
  378.     local running = true
  379.     local last_c = tick()
  380.    
  381.     local click_start = tick()
  382.     mouse.Button1Down:connect(function()
  383.         if not running or anim_equip > 0 then return end
  384.         if tick() - attack_perform <= Settings.Attack_speed then return end
  385.         attack_perform = tick()
  386.         last_action = tick()
  387.         attack_type = math.random(1, 3)
  388.         idle_perform = 0
  389.         PlaySound("swing", 0.1)
  390.         Slash(0.1)
  391.     end)
  392.    
  393.     local conn = rs.RenderStepped:connect(function()
  394.         if not running then return end
  395.         local delta = tick() - last_c
  396.         last_c = tick()
  397.        
  398.         if anim_equip > 0 then
  399.             anim_equip = math.max(0, anim_equip - (delta / Settings.Equip_time))
  400.             Animate("Equip", 1 - anim_equip)
  401.         elseif tick() - attack_perform <= Settings.Attack_speed then
  402.             Animate("Attack" .. attack_type, (tick() - attack_perform) / Settings.Attack_speed)
  403.             idle_perform = 0
  404.         elseif tick() - idle_perform <= Settings.Idle_speed then
  405.             Animate("Idle" .. idle_type, (tick() - idle_perform) / Settings.Idle_speed)
  406.         else
  407.             Animate("Default", 0)
  408.         end
  409.        
  410.         if tick() - last_action >= idle_rand then
  411.             idle_rand = math.random(12, 20)
  412.             last_action = tick()
  413.             idle_perform = tick()
  414.             idle_type = math.random(1, 2)
  415.         end
  416.        
  417.     end)
  418.     tool.Deselected:connect(function() running = false conn:disconnect() end)
  419. end)
  420. tool.Deselected:connect(function()
  421.     RemoveSounds()
  422.     humanoid.WalkSpeed = walkspeeds[1]
  423. end)
  424.  
  425. --Murderer knife animation module, original code from The Mad Murderer, by loleris.
  426.  
  427. local mouse = pl_mouse
  428.  
  429. local conn_type = "Snap"
  430.  
  431. local anim_head = false
  432.  
  433. weapon_properties = {
  434.     mesh_id = "http://www.roblox.com/asset/?id=10604848",
  435.     texture_id = "http://www.roblox.com/asset/?id=10605252",  
  436.     scale = Vector3.new(0.5, 0.5, 0.5),
  437.     transparency = 0,
  438.     reflectance = 0,
  439.     brick_color = BrickColor.new("Really black"),
  440. }
  441.  
  442. --How did I make all of this? Magic. Didn't even need an animation editor :)
  443. Animations = {
  444.     Default = {
  445.         {{}, 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)}
  446.     },
  447.     Equip = {
  448.         {{}, 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)},
  449.         {{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)},
  450.         {{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)},
  451.     },
  452.     Idle1 = {
  453.         {{}, 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)},
  454.         {{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)},
  455.         {{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)},
  456.         {{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)},
  457.     },
  458.     Idle2 = {
  459.         {{}, 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)},
  460.         {{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)},
  461.         {{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)},
  462.         {{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)},
  463.         {{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)}
  464.     },
  465.     Attack1 = {
  466.         {{}, 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)},
  467.         {{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)},
  468.         {{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)},
  469.         {{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)}
  470.     },
  471.     Attack2 = {
  472.         {{}, 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)},
  473.         {{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)},
  474.         {{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)},
  475.         {{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)}
  476.     },
  477.     Attack3 = {
  478.         {{}, 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)},
  479.         {{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)},
  480.         {{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)},
  481.         {{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.
  482.     }
  483. }
  484.  
  485.  
  486. function CFrameTrans(GetCFrame1, GetCFrame2, GetNumber)
  487.     local Diff2 = GetCFrame2.p - GetCFrame1.p
  488.     GetCFrame1_s = GetCFrame1 - GetCFrame1.p
  489.     GetCFrame2 = GetCFrame2 - GetCFrame2.p
  490.     local Diff = GetCFrame1_s:inverse() * GetCFrame2
  491.     local x1, y1, z1 = Diff:toEulerAnglesXYZ()
  492.     return (GetCFrame1 + (Diff2 * GetNumber)) * CFrame.Angles(x1 * GetNumber, y1 * GetNumber, z1 * GetNumber)
  493. end
  494.  
  495. function TransEff(x, type)
  496.     if type == 1 then
  497.         return x
  498.     elseif type == 2 then
  499.         return x*x*(3 - 2*x)
  500.     elseif type == 3 then
  501.         return math.sin(math.rad(x * 90))
  502.     elseif type == 4 then
  503.         return 1 - math.sin(math.rad((1 - x) * 90))
  504.     end
  505. end
  506.  
  507. function num_trans(n1, n2, x)
  508.     return n1 + ((n2 - n1) * x)
  509. end
  510.  
  511. function PlayAnimation(anim_name, tm) --return {left, right, wep, trans}
  512.     tm = math.min(1, math.max(0, tm))
  513.     local animd = Animations[anim_name]
  514.     if #animd == 1 then
  515.         return {animd[1][3], animd[1][4], animd[1][5], animd[1][2]}
  516.     else
  517.         local trans_from = 1
  518.         local trans_to = 1
  519.         local tm_left = tm
  520.         for i = 2, #animd do
  521.             tm_left = tm_left - animd[i][1][1]
  522.             if tm_left <= 0 then
  523.                 trans_from = i - 1
  524.                 trans_to = i
  525.                 break
  526.             end
  527.         end
  528.         local trans_amm = TransEff((animd[trans_to][1][1] + tm_left) / animd[trans_to][1][1], animd[trans_to][1][2])
  529.         return {
  530.             CFrameTrans(animd[trans_from][3], animd[trans_to][3], trans_amm),
  531.             CFrameTrans(animd[trans_from][4], animd[trans_to][4], trans_amm),
  532.             CFrameTrans(animd[trans_from][5], animd[trans_to][5], trans_amm),
  533.             num_trans(animd[trans_from][2], animd[trans_to][2], trans_amm)
  534.         }
  535.     end
  536. end
  537.  
  538. rot_amplitude_head = 20
  539. rot_amplitude_chest = 15
  540.  
  541. anim_p = {
  542.     cam_offset = CFrame.new(0.2, -0.37, 0.91) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0)),
  543.     aim_amp = 0.5,
  544.     aim_max_change = 4,
  545.     aim_retract = 15,
  546.     aim_max_deg = 20,
  547. }
  548.  
  549. local weapon_model = Instance.new("Part")
  550. weapon_model.CanCollide = false
  551. weapon_model.Name = "WeaponObject"
  552. weapon_model.formFactor = "Custom"
  553. weapon_model.Size = Vector3.new(0.2, 0.2, 0.2)
  554. weapon_model.TopSurface = 0
  555. weapon_model.BottomSurface = 0
  556. weapon_model.BrickColor = weapon_properties.brick_color
  557. weapon_model.Transparency = weapon_properties.transparency
  558. weapon_model.Reflectance = weapon_properties.reflectance
  559. local mesh = Instance.new("SpecialMesh", weapon_model)
  560. mesh.Scale = weapon_properties.scale
  561. mesh.MeshId = weapon_properties.mesh_id
  562. mesh.TextureId = weapon_properties.texture_id
  563.  
  564. torso = character.Torso
  565. head = character.Head
  566.  
  567. motors = {torso:findFirstChild("Left Shoulder"), torso:findFirstChild("Right Shoulder"), torso:findFirstChild("Neck")}
  568. welds = {nil, nil, nil}
  569. weapon_parts = {weapon_model:clone(), weapon_model:clone()}
  570. weapon_model = nil
  571.  
  572. function EndAnimation()
  573.     if motors[1] then
  574.         motors[1].Part1 = character:findFirstChild("Left Arm")
  575.     end
  576.     if motors[2] then
  577.         motors[2].Part1 = character:findFirstChild("Right Arm")
  578.     end
  579.     if motors[3] then
  580.         motors[3].Part1 = character:findFirstChild("Head")
  581.     end
  582.     if welds[1] then
  583.         welds[1]:remove()
  584.         welds[1] = nil
  585.     end
  586.     if welds[2] then
  587.         welds[2]:remove()
  588.         welds[2] = nil
  589.     end
  590.     if welds[3] then
  591.         welds[3]:remove()
  592.         welds[3] = nil
  593.     end
  594.     weapon_parts[1].Parent = nil
  595.     if weapon_model then
  596.         weapon_model.Parent = nil
  597.     end
  598.     coroutine.resume(coroutine.create(function()
  599.         local swm = weapon_model
  600.         wait()
  601.         swm.Parent = nil
  602.         wait(0.1)
  603.         swm.Parent =  nil
  604.         wait(0.5)
  605.         swm.Parent =  nil
  606.     end))
  607. end
  608.  
  609. local anim_model = Instance.new("Model")
  610. anim_model.Name = "WeaponAnimation"
  611. weapon_model = anim_model
  612.    
  613. local cam_larm = Instance.new("Part")
  614. cam_larm.Parent = anim_model
  615. cam_larm.BrickColor = BrickColor.new("Really black")
  616. cam_larm.formFactor = "Custom"
  617. cam_larm.Size = Vector3.new(0.2, 0.2, 0.2)
  618. cam_larm.TopSurface = 0
  619. cam_larm.BottomSurface = 0
  620. cam_larm.Transparency = 0.4
  621. cam_larm.CanCollide = false
  622. local hmesh = Instance.new("BlockMesh", cam_larm)
  623. hmesh.Scale = Vector3.new(5, 10, 5)
  624.  
  625. local cam_rarm = cam_larm:clone()
  626. cam_rarm.Parent = anim_model
  627.  
  628. function StartAnimation()
  629.     local check = {torso:findFirstChild("LeftWeld"), torso:findFirstChild("RightWeld"), torso:findFirstChild("HeadWeld")}
  630.     if check[1] then check[1]:remove() end
  631.     if check[2] then check[2]:remove() end
  632.     if check[3] then check[3]:remove() end
  633.     local check2 = {character:findFirstChild("WeaponObject"), camera:findFirstChild("WeaponAnimation")}
  634.     if check2[1] then check2[1].Parent = nil end
  635.     if check2[2] then check2[2].Parent = nil end
  636.     if motors[1] then
  637.         motors[1].Part1 = nil
  638.     end
  639.     if motors[2] then
  640.         motors[2].Part1 = nil
  641.     end
  642.     if motors[3] then
  643.         motors[3].Part1 = nil
  644.     end
  645.     welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  646.     welds[1].Part0 = torso
  647.     welds[2].Part0 = torso
  648.     welds[3].Part0 = torso
  649.     welds[1].Part1 = character:findFirstChild("Left Arm")
  650.     welds[2].Part1 = character:findFirstChild("Right Arm")
  651.     welds[3].Part1 = character:findFirstChild("Head")
  652.     welds[1].Name = "LeftWeld"
  653.     welds[2].Name = "RightWeld"
  654.     welds[2].Name = "HeadWeld"
  655.     welds[1].C0 = CFrame.new(-1.5, 0, 0)
  656.     welds[2].C0 = CFrame.new(1.5, 0, 0)
  657.     welds[3].C0 = CFrame.new(0, 1.5, 0)
  658.     welds[1].Parent = torso
  659.     welds[2].Parent = torso
  660.     welds[3].Parent = torso
  661.    
  662.     weapon_parts[1].Parent = character
  663.     local wep_weld = Instance.new(conn_type)
  664.     wep_weld.Part0 = character:findFirstChild("Right Arm")
  665.     wep_weld.Part1 = weapon_parts[1]
  666.     wep_weld.C0 = CFrame.new()
  667.     wep_weld.Parent = weapon_parts[1]
  668.    
  669.     local weld1 = welds[1]
  670.     local weld2 = welds[2]
  671.     local weld3 = welds[3]
  672.    
  673.     local cam_welds = {Instance.new(conn_type), Instance.new(conn_type), Instance.new(conn_type)}
  674.     cam_welds[1].Part0 = torso
  675.     cam_welds[1].Part1 = cam_larm
  676.     cam_welds[1].Parent = cam_larm
  677.     cam_welds[2].Part0 = torso
  678.     cam_welds[2].Part1 = cam_rarm
  679.     cam_welds[2].Parent = cam_rarm
  680.     cam_welds[3].Part0 = cam_rarm
  681.     cam_welds[3].Part1 = weapon_parts[2]
  682.     cam_welds[3].Parent = weapon_parts[2]
  683.     weapon_parts[2].Parent = anim_model
  684.    
  685.     local move_anim_speed = 3
  686.     local last_p = Vector3.new()
  687.     local move_amm = 0
  688.     coroutine.resume(coroutine.create(function()
  689.         while weld1.Parent ~= nil do
  690.             local delta = wait(1/25)
  691.             local cur_p = torso.Position
  692.             if (cur_p - last_p).magnitude >= 0.1 then
  693.                 move_amm = math.min(1, move_amm + delta * move_anim_speed)
  694.             else
  695.                 move_amm = math.max(0, move_amm - delta * move_anim_speed)
  696.             end
  697.             last_p = cur_p
  698.         end
  699.     end))
  700.    
  701.     local r_serv = game:GetService("RunService")
  702.    
  703.     --EASTER EGG
  704.     function easein(x)
  705.         return math.sin(math.rad(x * 90))
  706.     end
  707.  
  708.     local a_horse = (character:findFirstChild("HorseHead") ~= nil)
  709.     local horse_displace = {0, 0}
  710.     local horse_cf = CFrame.Angles(0.0001, 0.0001, 0)
  711.     if a_horse then
  712.         coroutine.resume(coroutine.create(function()
  713.             while weld1.Parent ~= nil do
  714.                 local rndwait = (math.random(100, 1000) / 1000) * 4
  715.                 wait(rndwait)
  716.                 local oldd = {horse_displace[1], horse_displace[2]}
  717.                 local disp2 = {math.random(-60, 60), math.random(0, 25)}
  718.                
  719.                 local ld = 0
  720.                 while ld ~= 1 do
  721.                     local st = tick()
  722.                     r_serv.RenderStepped:wait()
  723.                     ld = math.min(1, ld + ((tick() - st) * 4))
  724.                     local eff = easein(ld)
  725.                    
  726.                     local x = oldd[1] - ((oldd[1] - disp2[1]) * eff)
  727.                     local y = oldd[2] - ((oldd[2] - disp2[2]) * eff)
  728.                     horse_displace = {x, y}
  729.                     horse_cf = CFrame.Angles(math.rad(y), math.rad(x) , 0)
  730.                 end
  731.             end
  732.         end))
  733.     end
  734.    
  735.     --EASTER EGG
  736.    
  737.     local last_va = 0
  738.     local last_va2 = 0
  739.     local view_velocity = {0, 0}
  740.    
  741.     coroutine.resume(coroutine.create(function()
  742.         local last_time = tick()
  743.         while weld1.Parent ~= nil do
  744.             r_serv.RenderStepped:wait() ------------------------------------------------
  745.             local delta = tick() - last_time
  746.             last_time = tick()
  747.            
  748.             local breathe_amp = 2
  749.             local breathe_freq = 0.8
  750.             local breathe = math.sin(math.rad(tick() * 90 * breathe_freq)) * breathe_amp
  751.            
  752.             local shake_freq = 5
  753.             local shake_amp = {0.05, 0.05}
  754.             local arm_shake = CFrame.new(
  755.                 math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[1],
  756.                 0,
  757.                 math.abs(math.sin(math.rad(tick() * 90 * shake_freq)) * move_amm * shake_amp[2]))
  758.  
  759.  
  760.             --ANIMATION LOOP
  761.             local p_distance = (head.Position - mouse.Hit.p).magnitude
  762.             if p_distance == 0 then p_distance = 0.0001 end
  763.             local p_height = mouse.Hit.p.y - head.Position.y
  764.             local view_angle
  765.             if p_height ~= 0 then
  766.                 view_angle = math.deg(math.asin(math.abs(p_height) / p_distance)) * (math.abs(p_height) / p_height)
  767.             else
  768.                 view_angle = 0
  769.             end
  770.            
  771.             local cam_cf = camera.CoordinateFrame
  772.             local looking_at = cam_cf * CFrame.new(0, 0, -100)
  773.             local view_angle2 = math.deg(math.atan2(cam_cf.p.x - looking_at.p.x, cam_cf.p.z - looking_at.p.z)) + 180
  774.            
  775.             local v_delta1, v_delta2
  776.             local dir1 = 0
  777.             local dir2 = 0
  778.             v_delta1 = math.abs(view_angle - last_va)
  779.             if v_delta1 ~= 0 then
  780.                 dir1 = (view_angle - last_va) / v_delta1
  781.             end
  782.             local va_check = {math.abs(view_angle2 - last_va2), 360 - math.abs(view_angle2 - last_va2)}
  783.             if view_angle2 == last_va2 then
  784.                 dir2 = 0
  785.                 v_delta2 = 0
  786.             elseif va_check[1] < va_check[2] then
  787.                 v_delta2 = va_check[1]
  788.                 dir2 = (view_angle2 - last_va2) / va_check[1]
  789.             else
  790.                 v_delta2 = va_check[2]
  791.                 if last_va2 > view_angle2 then
  792.                     dir2 = 1
  793.                 else
  794.                     dir2 = -1
  795.                 end
  796.             end
  797.             last_va = view_angle
  798.             last_va2 = view_angle2
  799.            
  800.             view_velocity[1] = view_velocity[1] / (1 + (delta * anim_p.aim_retract))
  801.             view_velocity[2] = view_velocity[2] / (1 + (delta * anim_p.aim_retract))
  802.            
  803.             local calc1 = v_delta1 * dir1 * anim_p.aim_amp
  804.             if calc1 ~= 0 then
  805.                 view_velocity[1] = view_velocity[1] + (math.min(anim_p.aim_max_change, math.abs(calc1)) * (calc1 / math.abs(calc1)))
  806.             end
  807.             local calc2 = v_delta2 * dir2 * anim_p.aim_amp
  808.             if calc2 ~= 0 then
  809.                 view_velocity[2] = view_velocity[2] + (math.min(anim_p.aim_max_change, math.abs(calc2)) * (calc2 / math.abs(calc2)))
  810.             end
  811.            
  812.             if view_velocity[1] ~= 0 then
  813.                 view_velocity[1] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[1])) * (math.abs(view_velocity[1]) / view_velocity[1])
  814.             end
  815.             if view_velocity[2] ~= 0 then
  816.                 view_velocity[2] = math.min(anim_p.aim_max_deg, math.abs(view_velocity[2])) * (math.abs(view_velocity[2]) / view_velocity[2])
  817.             end
  818.            
  819.             local anmtp = _G.MurderKnife_AnimType
  820.             local anmst = _G.MurderKnife_AnimState
  821.            
  822.             if anmst == nil then
  823.                 anmst = 0
  824.             end
  825.            
  826.             if anmtp ~= nil then
  827.                 if Animations[anmtp] == nil then
  828.                     anmtp = "Default"
  829.                 end
  830.             else
  831.                 anmtp = "Default"
  832.             end
  833.             local curr_anim = PlayAnimation(anmtp, anmst) --left, right, weapon, wep trans
  834.            
  835.             --curr_anim = {Animations.Default[1][3], Animations.Default[1][4], Animations.Default[1][5], 0}
  836.            
  837.             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)
  838.             weld1.C1 = (chestCF * curr_anim[1] * CFrame.new(0, -0.5, 0)):inverse()
  839.             weld2.C1 = (chestCF * curr_anim[2] * CFrame.new(0, -0.5, 0)):inverse()
  840.             wep_weld.C1 = (curr_anim[3]):inverse()
  841.             weapon_parts[1].Transparency = curr_anim[4]
  842.             if anim_head then
  843.                 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()
  844.             else
  845.                 weld3.C1 = (CFrame.new(0, 0, 0)):inverse()
  846.             end
  847.            
  848.             if (head.Position - camera.CoordinateFrame.p).magnitude < 3 then
  849.                 if anim_model.Parent == nil then
  850.                     anim_model.Parent = camera
  851.                 end
  852.                 cam_welds[1].Parent = cam_larm
  853.                 cam_welds[2].Parent = cam_rarm
  854.                 cam_welds[3].Parent = weapon_parts[2]
  855.                 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
  856.                 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()
  857.                 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()
  858.                 cam_welds[3].C1 = (curr_anim[3]):inverse()
  859.                 weapon_parts[2].Transparency = curr_anim[4]
  860.             else
  861.                 if anim_model.Parent ~= nil then
  862.                     anim_model.Parent = nil
  863.                 end
  864.             end
  865.             --ANIMATION LOOP
  866.         end
  867.     end))
  868. end
  869.  
  870. local last_st = 0
  871. local eq = false
  872. tool.Selected:connect(function(mouse)
  873.     if eq then return end
  874.     eq = true
  875.     wait()
  876.     StartAnimation()
  877. end)
  878.  
  879. tool.Deselected:connect(function()
  880.     eq = false
  881.     EndAnimation()
  882. end)
  883.  
  884. local p = game.Players.LocalPlayer.Character
  885. local weld = Instance.new("Weld",p.Torso)
  886. weld.Part0 = p.Torso
  887. local weld2 = Instance.new("Weld",p.Torso)
  888. weld2.Part0 = p.Torso
  889. local Smoke = Instance.new("Part",p.Torso)
  890. Smoke.Anchored = true
  891. Smoke.CanCollide = false
  892. Smoke.Size = Vector3.new(1,1,1)
  893. Smoke.CustomPhysicalProperties = PhysicalProperties.new(0,0,0,0,0)
  894. weld2.Part1 = Smoke
  895. weld2.C1 = CFrame.new(0,-4,3.5)-- * CFrame.Angles(0,math.rad(180),0)
  896. Smoke.Anchored = false
  897. Smoke.Transparency = 1;
  898.  
  899. local Particle = Instance.new("ParticleEmitter",Smoke)
  900. Particle.Rate = 3;
  901. Particle.Speed = NumberRange.new(30,30);
  902. Particle.VelocitySpread = 40;
  903. Particle.Texture = "rbxassetid://3412753"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement