Advertisement
KrYn0MoRe

among us kill tool

Oct 1st, 2020 (edited)
12,718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.55 KB | None | 0 0
  1. local junk = workspace
  2.  
  3. function limb_collide(obj,mode,d)
  4.     if (obj:IsA("BasePart")) and not obj:FindFirstChild('limb') then else return end
  5.     local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
  6.     if not exists then
  7.         game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
  8.     end
  9.     game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
  10.     --
  11.     local t = {}
  12.     --
  13.     local cb = Instance.new("Part")
  14.     cb.Name = 'limb'
  15.     cb.Transparency = 1
  16.     cb.CanCollide = true
  17.     cb.Anchored = false
  18.     cb.CFrame = obj.CFrame
  19.     cb.Size = obj.Size*0.9
  20.     cb.Massless = true
  21.     cb.Locked = true
  22.     game:GetService("PhysicsService"):SetPartCollisionGroup(cb,'Limb Collide')
  23.     game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
  24.     local weld = Instance.new("Weld")
  25.     weld.Part0 = cb
  26.     weld.Part1 = obj
  27.     weld.Parent = cb
  28.     obj.Massless = true
  29.     obj.Anchored = false
  30.     if mode or obj:FindFirstChild("Dismembered") then
  31.         cb.Parent = junk -- .Parent
  32.     else
  33.         cb.Parent = junk
  34.         table.insert(t,1,cb)
  35.     end
  36.     if d then
  37.         game:GetService("Debris"):AddItem(cb,d)
  38.     end
  39.     --
  40.     if not string.match(obj.Name:lower(),'torso') and not string.match(obj.Name:lower(),'rootpart') and not string.match(obj.Name:lower(),'head') then
  41.         local lv = Vector3.new() -- Vector3.new(cb.Size.X,0,cb.Size.Z)
  42.         local cb2 = Instance.new("Part")
  43.         cb2.Name = 'limb'
  44.         cb2.Transparency = 1
  45.         cb2.CanCollide = true
  46.         cb2.Anchored = false
  47.         cb2.CFrame = obj.CFrame
  48.         cb2.Size = lv
  49.         cb2.Massless = true
  50.         cb2.Locked = true
  51.         --game:GetService("PhysicsService"):SetPartCollisionGroup(cb2,'Limb Collide')
  52.         local weld2 = Instance.new("Weld")
  53.         weld2.Part0 = cb
  54.         weld2.Part1 = cb2
  55.         weld2.C1 = CFrame.new(0,(cb.Size.Y/2),0)
  56.         weld2.Parent = cb2
  57.         if mode or obj:FindFirstChild("Dismembered") then
  58.             cb2.Parent = junk -- .Parent
  59.         else
  60.             cb2.Parent = junk
  61.             table.insert(t,1,cb2)
  62.         end
  63.         if d then
  64.             game:GetService("Debris"):AddItem(cb2,d)
  65.         end
  66.     end
  67.     --
  68.     return t
  69. end
  70.  
  71. function recurse(root,callback,i)
  72.     i= i or 0
  73.     for _,v in pairs(root:GetChildren()) do
  74.         i = i + 1
  75.         callback(i,v)
  76.  
  77.         if #v:GetChildren() > 0 then
  78.             i = recurse(v,callback,i)
  79.         end
  80.     end
  81.  
  82.     return i
  83. end
  84.  
  85. function ragdollJoint(character, part0, part1, attachmentName, className, properties)
  86.     attachmentName = attachmentName.."RigAttachment"
  87.     local constraint = Instance.new(className.."Constraint")
  88.     constraint.Attachment0 = part0:FindFirstChild(attachmentName)
  89.     constraint.Attachment1 = part1:FindFirstChild(attachmentName)
  90.     constraint.Name = "RagdollConstraint"..part1.Name
  91.  
  92.     for _,propertyData in next,properties or {} do
  93.         constraint[propertyData[1]] = propertyData[2]
  94.     end
  95.  
  96.     constraint.Parent = character
  97. end
  98.  
  99. function getAttachment0(character, attachmentName)
  100.     for _,child in next,character:GetChildren() do
  101.         local attachment = child:FindFirstChild(attachmentName)
  102.         if attachment then
  103.             return attachment
  104.         end
  105.     end
  106. end
  107.  
  108. function ragdoll(targchar,kill,remove)
  109.     if targchar then else return end
  110.     local targplr
  111.     pcall(function()
  112.         targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
  113.     end)
  114.     local pc = targchar
  115.     local targhum = pc:FindFirstChildOfClass("Humanoid")
  116.     local js,js2 = {},{}
  117.     local lc = {}
  118.  
  119.     targhum.PlatformStand = true
  120.     --if kill then
  121.     local old_pc
  122.     if remove then
  123.         pc.Archivable = true
  124.         old_pc = pc
  125.         pc = pc:Clone()
  126.     end
  127.     for i,v in pairs(pc:GetDescendants()) do
  128.         if v.Name ~= 'HumanoidRootPart' and v.Name ~= 'Torso' and v:IsA("BasePart") then
  129.             if remove or not kill then
  130.                 local t = limb_collide(v,false,10)
  131.                 table.insert(lc,1,t)
  132.             end
  133.         end
  134.         if kill then
  135.             if v:IsA("ParticleEmitter") then
  136.                 v.Enabled = false
  137.             end
  138.             if v:IsA("SelectionBox") or v:IsA("BodyVelocity") or v:IsA("BodyPosition") or v:IsA("BodyAngularVelocity") or v:IsA("BodyForce") or v:IsA("BodyGyro") or v:IsA("BodyThrust") or v:IsA("BodyMover") then
  139.                 if v:IsA("BodyVelocity") then
  140.                     game:GetService("Debris"):AddItem(v,0.15)
  141.                 else
  142.                     v:Destroy()
  143.                 end
  144.             end
  145.             if (v:IsA("Script") and v.Name == 'Health') or (v:IsA("LocalScript") and v.Name == 'Animate') then
  146.                 v:Destroy()
  147.             end
  148.             if v:IsA("Humanoid") then
  149.                 v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
  150.                 v.PlatformStand = true
  151.             end
  152.         end
  153.     end
  154.     if remove then
  155.         for i,v in pairs(old_pc:GetDescendants()) do
  156.             if v:IsA("BasePart") or v:IsA("ForceField") or v:IsA("Accessory") or v:IsA("Decal") or v:IsA("Texture") or v:IsA("SurfaceGui") then
  157.                 v:destroy()
  158.             end
  159.             if v:IsA("Humanoid") then
  160.                 v.BreakJointsOnDeath = true
  161.                 v.Health = 0
  162.                 v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
  163.                 v.PlatformStand = true
  164.             end
  165.         end
  166.         pc.Parent = junk
  167.         game:GetService("Debris"):AddItem(pc,10)
  168.     end
  169.     --end
  170.     --if kill and targhum:FindFirstChild("Ragdolled") then return; end;
  171.     coroutine.resume(coroutine.create(function()
  172.         if targplr then
  173.             for i,v in pairs(pc:GetChildren()) do
  174.                 if v:IsA("BasePart") then
  175.                     --v.Massless = true
  176.                     if v:CanSetNetworkOwnership() then
  177.                         v:SetNetworkOwner(targplr)
  178.                     end
  179.                 end
  180.             end
  181.         end
  182.     end))
  183.     local kb = 15
  184.     local root = pc:FindFirstChild("HumanoidRootPart")
  185.     local targtorso = pc:FindFirstChild("Torso") or pc:FindFirstChild("UpperTorso") or pc:FindFirstChild("Head") or pc:FindFirstChild("HumanoidRootPart")
  186.     if targtorso then else return end
  187.     local dir = targtorso.CFrame.lookVector*-1
  188.     local bv = Instance.new("BodyVelocity")
  189.     bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  190.     bv.Velocity = --[[dir*kb+]]Vector3.new(0,kb,0)
  191.     bv.Parent = targtorso
  192.     game:GetService("Debris"):AddItem(bv,0.1)
  193.     if kill then
  194.         local ragval = Instance.new("ObjectValue")
  195.         ragval.Name = 'Ragdolled'
  196.         ragval.Parent = targhum
  197.     end
  198.     coroutine.resume(coroutine.create(function()
  199.         if (targhum.RigType == Enum.HumanoidRigType.R6 or (targhum.RigType == Enum.HumanoidRigType.R15 and not kill)) then
  200.             for _,m in pairs(pc:GetChildren()) do
  201.                 for _,v in pairs(m:GetChildren()) do
  202.                     if (v:IsA("Snap") --[[or v:IsA('Weld') or v:IsA("BallSocketConstraint")]]) and kill then
  203.                         v:Destroy()
  204.                     end
  205.                     if (v:IsA('Motor6D') or v:IsA('Motor') or v:IsA("Weld")) and (v.Parent:IsA("BasePart")) then
  206.                         if not kill then
  207.                             table.insert(js2,1,{obj = v,par = v.Parent})
  208.                         end
  209.  
  210.                         local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
  211.                         a0.CFrame = v.C0
  212.                         a1.CFrame = v.C1
  213.                         a0.Parent = v.Part0
  214.                         a1.Parent = v.Part1
  215.  
  216.                         local b = Instance.new("BallSocketConstraint")
  217.                         b.Attachment0 = a0
  218.                         b.Attachment1 = a1
  219.                         b.Parent = v.Part0
  220.                         --b.TwistLimitsEnabled = true
  221.                         --b.LimitsEnabled = true
  222.  
  223.                         v.Parent = nil
  224.                         table.insert(js,1,b)
  225.                     end
  226.                 end
  227.             end
  228.         elseif targhum.RigType == Enum.HumanoidRigType.R15 and kill then
  229.             local character = targchar
  230.             recurse(character, function(_,v)
  231.                 if v:IsA("Attachment") then
  232.                     v.Axis = Vector3.new(0, 1, 0)
  233.                     v.SecondaryAxis = Vector3.new(0, 0, 1)
  234.                     v.Rotation = Vector3.new(0, 0, 0)
  235.                 end
  236.             end)
  237.  
  238.             --Re-attach hats
  239.             for _,child in next,character:GetChildren() do
  240.                 if child:IsA("Accoutrement") then
  241.                     --Loop through all parts instead of only checking for one to be forwards-compatible in the event
  242.                     --ROBLOX implements multi-part accessories
  243.                     for _,part in next,child:GetChildren() do
  244.                         if part:IsA("BasePart") then
  245.                             local attachment1 = part:FindFirstChildOfClass("Attachment")
  246.                             local attachment0 = getAttachment0(character, attachment1.Name)
  247.                             if attachment0 and attachment1 then
  248.                                 --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
  249.                                 --joints connecting a character are perpetually deleted while the character is dead
  250.                                 local constraint = Instance.new("HingeConstraint")
  251.                                 constraint.Attachment0 = attachment0
  252.                                 constraint.Attachment1 = attachment1
  253.                                 constraint.LimitsEnabled = true
  254.                                 constraint.UpperAngle = 0 --Simulate weld by making it difficult for constraint to move
  255.                                 constraint.LowerAngle = 0
  256.                                 constraint.Parent = character
  257.                             end
  258.                         end
  259.                     end
  260.                 end
  261.             end
  262.  
  263.             ragdollJoint(character, character.LowerTorso, character.UpperTorso, "Waist", "BallSocket", {
  264.                 {"LimitsEnabled",true};
  265.                 {"UpperAngle",5};
  266.             })
  267.             ragdollJoint(character, character.UpperTorso, character.Head, "Neck", "BallSocket", {
  268.                 {"LimitsEnabled",true};
  269.                 {"UpperAngle",15};
  270.             })
  271.  
  272.             local handProperties = {
  273.                 {"LimitsEnabled", true};
  274.                 {"UpperAngle",0};
  275.                 {"LowerAngle",0};
  276.             }
  277.             ragdollJoint(character, character.LeftLowerArm, character.LeftHand, "LeftWrist", "Hinge", handProperties)
  278.             ragdollJoint(character, character.RightLowerArm, character.RightHand, "RightWrist", "Hinge", handProperties)
  279.  
  280.             local shinProperties = {
  281.                 {"LimitsEnabled", true};
  282.                 {"UpperAngle", 0};
  283.                 {"LowerAngle", -75};
  284.             }
  285.             ragdollJoint(character, character.LeftUpperLeg, character.LeftLowerLeg, "LeftKnee", "Hinge", shinProperties)
  286.             ragdollJoint(character, character.RightUpperLeg, character.RightLowerLeg, "RightKnee", "Hinge", shinProperties)
  287.  
  288.             local footProperties = {
  289.                 {"LimitsEnabled", true};
  290.                 {"UpperAngle", 15};
  291.                 {"LowerAngle", -45};
  292.             }
  293.             ragdollJoint(character, character.LeftLowerLeg, character.LeftFoot, "LeftAnkle", "Hinge", footProperties)
  294.             ragdollJoint(character, character.RightLowerLeg, character.RightFoot, "RightAnkle", "Hinge", footProperties)
  295.  
  296.             --TODO fix ability for socket to turn backwards whenn ConeConstraints are shipped
  297.             ragdollJoint(character, character.UpperTorso, character.LeftUpperArm, "LeftShoulder", "BallSocket")
  298.             ragdollJoint(character, character.LeftUpperArm, character.LeftLowerArm, "LeftElbow", "BallSocket")
  299.             ragdollJoint(character, character.UpperTorso, character.RightUpperArm, "RightShoulder", "BallSocket")
  300.             ragdollJoint(character, character.RightUpperArm, character.RightLowerArm, "RightElbow", "BallSocket")
  301.             ragdollJoint(character, character.LowerTorso, character.LeftUpperLeg, "LeftHip", "BallSocket")
  302.             ragdollJoint(character, character.LowerTorso, character.RightUpperLeg, "RightHip", "BallSocket")
  303.         end
  304.     end))
  305.     if root then
  306.         root.CanCollide = false
  307.     end
  308.     local c
  309.     if root then
  310.         c = root.Touched:Connect(function(obj)
  311.             if obj and not obj:IsDescendantOf(junk) and (root.Velocity.Magnitude >= 2) then
  312.                 local impact = Instance.new("Sound")
  313.                 impact.Parent = root
  314.                 impact.Name = 'impact'
  315.                 impact.SoundId = 'rbxassetid://' .. impacts[math.random(1,#impacts)]
  316.                 impact.Volume = 0.1
  317.                 impact.PlayOnRemove = true
  318.                 impact:Destroy()
  319.             end
  320.         end)
  321.     end
  322.     local function restore()
  323.         if c then
  324.             c:Disconnect()
  325.         end
  326.         if root then
  327.             root.CFrame = root.CFrame*CFrame.new(0,4,0)
  328.         end
  329.         for i,v in pairs(js) do
  330.             v:Destroy()
  331.         end
  332.         for i,v in pairs(lc) do
  333.             for i,v in pairs(v) do
  334.                 v:Destroy()
  335.             end
  336.         end
  337.         if targhum then
  338.             targhum.PlatformStand = false
  339.         end
  340.         for i,v in pairs(js2) do
  341.             v.obj.Parent = v.par
  342.         end
  343.         if root then
  344.             root.CanCollide = true
  345.         end
  346.     end
  347.     return restore
  348. end
  349.  
  350. local t = Instance.new("Tool")
  351. t.CanBeDropped = false
  352. local Part1 = Instance.new("Part")
  353. local Sound6 = Instance.new("Sound")
  354. t.Name = "Impostor Tool"
  355. t.TextureId = "rbxassetid://5701818647"
  356. t.Grip = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
  357. t.GripForward = Vector3.new(-1, -0, -0)
  358. t.GripPos = Vector3.new(0, 0, -1.5)
  359. t.GripRight = Vector3.new(0, 1, 0)
  360. t.GripUp = Vector3.new(0, 0, 1)
  361. Part1.Name = "Handle"
  362. Part1.Parent = t
  363. Part1.CFrame = CFrame.new(214.957138, 4.28734684, -190.317474, 0.0910440385, -0.881099463, 0.464084357, 0.537011683, 0.435894847, 0.722229123, -0.838648558, 0.183463722, 0.512845576)
  364. Part1.Orientation = Vector3.new(-46.2400017, 42.1399994, 50.9300003)
  365. Part1.Position = Vector3.new(214.957138, 4.28734684, -190.317474)
  366. Part1.Rotation = Vector3.new(-54.6199989, 27.6499996, 84.0999985)
  367. Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
  368. Part1.Size = Vector3.new()
  369. Part1.BottomSurface = Enum.SurfaceType.Smooth
  370. Part1.BrickColor = BrickColor.new("Dark stone grey")
  371. Part1.Locked = true
  372. Part1.Transparency = 1
  373. Part1.TopSurface = Enum.SurfaceType.Smooth
  374. Part1.brickColor = BrickColor.new("Dark stone grey")
  375. Part1.FormFactor = Enum.FormFactor.Plate
  376. Part1.formFactor = Enum.FormFactor.Plate
  377. Sound6.Name = "Kill"
  378. Sound6.Parent = nil
  379. Sound6.SoundId = "rbxassetid://5700183626"
  380. Sound6.Volume = 2
  381.  
  382. plr = owner
  383.  
  384. local Tool = t
  385. local Handle = Tool:WaitForChild("Handle")
  386. Tool.Parent = plr['Backpack']
  387.  
  388. local tag = Instance.new("ObjectValue")
  389. tag.Name = 'par'
  390. tag.Value = plr['Backpack']
  391. tag.Parent = t
  392.  
  393. local char = plr.Character
  394. local hum = char:FindFirstChildOfClass("Humanoid")
  395. local root = char:FindFirstChild("HumanoidRootPart")
  396.  
  397. local Players = game:GetService("Players")
  398. local Debris = game:GetService("Debris")
  399.  
  400. local Sounds = {
  401.     Kill = Sound6,
  402. }
  403.  
  404. local function CheckIfAlive()
  405.     return (((plr and plr.Parent and char and char.Parent and hum and hum.Parent and hum.Health > 0 and root and root.Parent) and true) or false)
  406. end
  407.  
  408. local can_kill = true
  409. local kill_cooldown = 1
  410. local kill_distance = 10
  411.  
  412. local function kill(Hit,dist)
  413.     if not Hit or not Hit.Parent or not CheckIfAlive() then
  414.         return
  415.     end
  416.     local character = Hit.Parent
  417.     if character == char then
  418.         return
  419.     end
  420.     local humanoid = character:FindFirstChildOfClass("Humanoid")
  421.     if not humanoid or humanoid.Health == 0 then
  422.         return
  423.     end
  424.     local player = Players:GetPlayerFromCharacter(character)
  425.     if player and ((player == plr)) then
  426.         return
  427.     end
  428.     if can_kill then
  429.         local sp = Instance.new("Part")
  430.         sp.Size = Vector3.new()
  431.         sp.Transparency = 1
  432.         sp.CanCollide = false
  433.         sp.Anchored = true
  434.         sp.Locked = true
  435.         sp.Position = root.Position
  436.         sp.Parent = script
  437.         local s1 = Sounds.Kill:Clone()
  438.         s1.Parent = sp
  439.         s1:Play()
  440.         local s2 = Sounds.Kill:Clone()
  441.         s2.SoundId = 'rbxassetid://6484812516'
  442.         s2.Parent = sp
  443.         s2:Play()
  444.         spawn(function()
  445.             root.Anchored = true
  446.             local sv = root.Velocity
  447.             local trans = {}
  448.             for i,v in pairs(char:GetDescendants()) do
  449.                 if (v:IsA("BasePart") or v:IsA("UnionOperation")) and 0 >= v.Transparency then
  450.                     trans[v] = true
  451.                     game:GetService("TweenService"):Create(v,TweenInfo.new(0.1),{Transparency = 1}):Play()
  452.                 end
  453.             end
  454.             game:GetService("TweenService"):Create(root,TweenInfo.new(0.1),{CFrame = Hit.CFrame}):Play()
  455.             humanoid:TakeDamage(1/0)
  456.             wait(0.1)
  457.             for i,v in pairs(trans) do
  458.                 game:GetService("TweenService"):Create(i,TweenInfo.new(0.1),{Transparency = 0}):Play()
  459.             end
  460.             root.Anchored = false
  461.             root.Velocity = sv
  462.             local tempkillval = Instance.new("ObjectValue")
  463.             tempkillval.Name = 'killer'
  464.             tempkillval.Value = nil -- plr
  465.             tempkillval.Parent = humanoid
  466.             humanoid:TakeDamage(1/0)
  467.             local ragval = Instance.new("ObjectValue")
  468.             ragval.Name = 'Ragdolled'
  469.             ragval.Parent = humanoid
  470.             humanoid.AutoRotate = false
  471.             humanoid.PlatformStand = true
  472.             ragdoll(character,true)
  473.         end)
  474.         spawn(function()
  475.             can_kill = false
  476.             Tool.Parent = nil
  477.             wait(kill_cooldown)
  478.             if not char or not hum or not root or 0 >= hum.Health then
  479.                 repeat
  480.                     wait(1)
  481.                     char = plr.Character
  482.                     hum = char:FindFirstChildOfClass("Humanoid")
  483.                     root = char:FindFirstChild("HumanoidRootPart")
  484.                 until char and hum and root and hum.Health > 0
  485.             end
  486.             Tool.Parent = plr['Backpack']
  487.             can_kill = true
  488.         end)
  489.     end
  490. end
  491.  
  492. local function get_near()
  493.     local dist = kill_distance
  494.     local near = nil
  495.     for i,v in pairs(workspace:GetChildren()) do
  496.         if v ~= char then else continue end
  497.         local tc = v
  498.         local tt = nil
  499.         local th = nil
  500.         pcall(function()
  501.             tt = tc:FindFirstChild("HumanoidRootPart") or tc:FindFirstChild("Torso") or tc:FindFirstChild("Head")
  502.         end)
  503.         pcall(function()
  504.             th = tc:FindFirstChildOfClass("Humanoid")
  505.         end)
  506.         if tc and tt and th and th.Health > 0 then
  507.             local cdi = (tt.Position-root.Position).Magnitude
  508.             if dist >= cdi then
  509.                 dist = cdi
  510.                 near = tt
  511.             end
  512.         end
  513.     end
  514.     return near,dist
  515. end
  516.  
  517. Tool.Equipped:Connect(function()
  518.     local near,dist = get_near()
  519.     if not near then
  520.         wait(0)
  521.         if not can_kill then
  522.             Tool.Parent = nil
  523.         else
  524.             if not char or not hum or not root or 0 >= hum.Health then
  525.                 repeat
  526.                     wait(1)
  527.                     char = plr.Character
  528.                     hum = char:FindFirstChildOfClass("Humanoid")
  529.                     root = char:FindFirstChild("HumanoidRootPart")
  530.                 until char and hum and root and hum.Health > 0
  531.             end
  532.             Tool.Parent = plr['Backpack']
  533.         end
  534.     else
  535.         kill(near)
  536.     end
  537. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement