Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local junk = workspace
- function limb_collide(obj,mode,d)
- if (obj:IsA("BasePart")) and not obj:FindFirstChild('limb') then else return end
- local exists = pcall(game:GetService("PhysicsService").GetCollisionGroupId, game:GetService("PhysicsService"), 'Limb Collide')
- if not exists then
- game:GetService("PhysicsService"):CreateCollisionGroup('Limb Collide')
- end
- game:GetService("PhysicsService"):CollisionGroupSetCollidable('Limb Collide','Limb Collide',false)
- --
- local t = {}
- --
- local cb = Instance.new("Part")
- cb.Name = 'limb'
- cb.Transparency = 1
- cb.CanCollide = true
- cb.Anchored = false
- cb.CFrame = obj.CFrame
- cb.Size = obj.Size*0.9
- cb.Massless = true
- cb.Locked = true
- game:GetService("PhysicsService"):SetPartCollisionGroup(cb,'Limb Collide')
- game:GetService("PhysicsService"):SetPartCollisionGroup(obj,'Limb Collide')
- local weld = Instance.new("Weld")
- weld.Part0 = cb
- weld.Part1 = obj
- weld.Parent = cb
- obj.Massless = true
- obj.Anchored = false
- if mode or obj:FindFirstChild("Dismembered") then
- cb.Parent = junk -- .Parent
- else
- cb.Parent = junk
- table.insert(t,1,cb)
- end
- if d then
- game:GetService("Debris"):AddItem(cb,d)
- end
- --
- 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
- local lv = Vector3.new() -- Vector3.new(cb.Size.X,0,cb.Size.Z)
- local cb2 = Instance.new("Part")
- cb2.Name = 'limb'
- cb2.Transparency = 1
- cb2.CanCollide = true
- cb2.Anchored = false
- cb2.CFrame = obj.CFrame
- cb2.Size = lv
- cb2.Massless = true
- cb2.Locked = true
- --game:GetService("PhysicsService"):SetPartCollisionGroup(cb2,'Limb Collide')
- local weld2 = Instance.new("Weld")
- weld2.Part0 = cb
- weld2.Part1 = cb2
- weld2.C1 = CFrame.new(0,(cb.Size.Y/2),0)
- weld2.Parent = cb2
- if mode or obj:FindFirstChild("Dismembered") then
- cb2.Parent = junk -- .Parent
- else
- cb2.Parent = junk
- table.insert(t,1,cb2)
- end
- if d then
- game:GetService("Debris"):AddItem(cb2,d)
- end
- end
- --
- return t
- end
- function recurse(root,callback,i)
- i= i or 0
- for _,v in pairs(root:GetChildren()) do
- i = i + 1
- callback(i,v)
- if #v:GetChildren() > 0 then
- i = recurse(v,callback,i)
- end
- end
- return i
- end
- function ragdollJoint(character, part0, part1, attachmentName, className, properties)
- attachmentName = attachmentName.."RigAttachment"
- local constraint = Instance.new(className.."Constraint")
- constraint.Attachment0 = part0:FindFirstChild(attachmentName)
- constraint.Attachment1 = part1:FindFirstChild(attachmentName)
- constraint.Name = "RagdollConstraint"..part1.Name
- for _,propertyData in next,properties or {} do
- constraint[propertyData[1]] = propertyData[2]
- end
- constraint.Parent = character
- end
- function getAttachment0(character, attachmentName)
- for _,child in next,character:GetChildren() do
- local attachment = child:FindFirstChild(attachmentName)
- if attachment then
- return attachment
- end
- end
- end
- function ragdoll(targchar,kill,remove)
- if targchar then else return end
- local targplr
- pcall(function()
- targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
- end)
- local pc = targchar
- local targhum = pc:FindFirstChildOfClass("Humanoid")
- local js,js2 = {},{}
- local lc = {}
- targhum.PlatformStand = true
- --if kill then
- local old_pc
- if remove then
- pc.Archivable = true
- old_pc = pc
- pc = pc:Clone()
- end
- for i,v in pairs(pc:GetDescendants()) do
- if v.Name ~= 'HumanoidRootPart' and v.Name ~= 'Torso' and v:IsA("BasePart") then
- if remove or not kill then
- local t = limb_collide(v,false,10)
- table.insert(lc,1,t)
- end
- end
- if kill then
- if v:IsA("ParticleEmitter") then
- v.Enabled = false
- end
- 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
- if v:IsA("BodyVelocity") then
- game:GetService("Debris"):AddItem(v,0.15)
- else
- v:Destroy()
- end
- end
- if (v:IsA("Script") and v.Name == 'Health') or (v:IsA("LocalScript") and v.Name == 'Animate') then
- v:Destroy()
- end
- if v:IsA("Humanoid") then
- v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
- v.PlatformStand = true
- end
- end
- end
- if remove then
- for i,v in pairs(old_pc:GetDescendants()) do
- 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
- v:destroy()
- end
- if v:IsA("Humanoid") then
- v.BreakJointsOnDeath = true
- v.Health = 0
- v.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
- v.PlatformStand = true
- end
- end
- pc.Parent = junk
- game:GetService("Debris"):AddItem(pc,10)
- end
- --end
- --if kill and targhum:FindFirstChild("Ragdolled") then return; end;
- coroutine.resume(coroutine.create(function()
- if targplr then
- for i,v in pairs(pc:GetChildren()) do
- if v:IsA("BasePart") then
- --v.Massless = true
- if v:CanSetNetworkOwnership() then
- v:SetNetworkOwner(targplr)
- end
- end
- end
- end
- end))
- local kb = 15
- local root = pc:FindFirstChild("HumanoidRootPart")
- local targtorso = pc:FindFirstChild("Torso") or pc:FindFirstChild("UpperTorso") or pc:FindFirstChild("Head") or pc:FindFirstChild("HumanoidRootPart")
- if targtorso then else return end
- local dir = targtorso.CFrame.lookVector*-1
- local bv = Instance.new("BodyVelocity")
- bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
- bv.Velocity = --[[dir*kb+]]Vector3.new(0,kb,0)
- bv.Parent = targtorso
- game:GetService("Debris"):AddItem(bv,0.1)
- if kill then
- local ragval = Instance.new("ObjectValue")
- ragval.Name = 'Ragdolled'
- ragval.Parent = targhum
- end
- coroutine.resume(coroutine.create(function()
- if (targhum.RigType == Enum.HumanoidRigType.R6 or (targhum.RigType == Enum.HumanoidRigType.R15 and not kill)) then
- for _,m in pairs(pc:GetChildren()) do
- for _,v in pairs(m:GetChildren()) do
- if (v:IsA("Snap") --[[or v:IsA('Weld') or v:IsA("BallSocketConstraint")]]) and kill then
- v:Destroy()
- end
- if (v:IsA('Motor6D') or v:IsA('Motor') or v:IsA("Weld")) and (v.Parent:IsA("BasePart")) then
- if not kill then
- table.insert(js2,1,{obj = v,par = v.Parent})
- end
- local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
- a0.CFrame = v.C0
- a1.CFrame = v.C1
- a0.Parent = v.Part0
- a1.Parent = v.Part1
- local b = Instance.new("BallSocketConstraint")
- b.Attachment0 = a0
- b.Attachment1 = a1
- b.Parent = v.Part0
- --b.TwistLimitsEnabled = true
- --b.LimitsEnabled = true
- v.Parent = nil
- table.insert(js,1,b)
- end
- end
- end
- elseif targhum.RigType == Enum.HumanoidRigType.R15 and kill then
- local character = targchar
- recurse(character, function(_,v)
- if v:IsA("Attachment") then
- v.Axis = Vector3.new(0, 1, 0)
- v.SecondaryAxis = Vector3.new(0, 0, 1)
- v.Rotation = Vector3.new(0, 0, 0)
- end
- end)
- --Re-attach hats
- for _,child in next,character:GetChildren() do
- if child:IsA("Accoutrement") then
- --Loop through all parts instead of only checking for one to be forwards-compatible in the event
- --ROBLOX implements multi-part accessories
- for _,part in next,child:GetChildren() do
- if part:IsA("BasePart") then
- local attachment1 = part:FindFirstChildOfClass("Attachment")
- local attachment0 = getAttachment0(character, attachment1.Name)
- if attachment0 and attachment1 then
- --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
- --joints connecting a character are perpetually deleted while the character is dead
- local constraint = Instance.new("HingeConstraint")
- constraint.Attachment0 = attachment0
- constraint.Attachment1 = attachment1
- constraint.LimitsEnabled = true
- constraint.UpperAngle = 0 --Simulate weld by making it difficult for constraint to move
- constraint.LowerAngle = 0
- constraint.Parent = character
- end
- end
- end
- end
- end
- ragdollJoint(character, character.LowerTorso, character.UpperTorso, "Waist", "BallSocket", {
- {"LimitsEnabled",true};
- {"UpperAngle",5};
- })
- ragdollJoint(character, character.UpperTorso, character.Head, "Neck", "BallSocket", {
- {"LimitsEnabled",true};
- {"UpperAngle",15};
- })
- local handProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle",0};
- {"LowerAngle",0};
- }
- ragdollJoint(character, character.LeftLowerArm, character.LeftHand, "LeftWrist", "Hinge", handProperties)
- ragdollJoint(character, character.RightLowerArm, character.RightHand, "RightWrist", "Hinge", handProperties)
- local shinProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 0};
- {"LowerAngle", -75};
- }
- ragdollJoint(character, character.LeftUpperLeg, character.LeftLowerLeg, "LeftKnee", "Hinge", shinProperties)
- ragdollJoint(character, character.RightUpperLeg, character.RightLowerLeg, "RightKnee", "Hinge", shinProperties)
- local footProperties = {
- {"LimitsEnabled", true};
- {"UpperAngle", 15};
- {"LowerAngle", -45};
- }
- ragdollJoint(character, character.LeftLowerLeg, character.LeftFoot, "LeftAnkle", "Hinge", footProperties)
- ragdollJoint(character, character.RightLowerLeg, character.RightFoot, "RightAnkle", "Hinge", footProperties)
- --TODO fix ability for socket to turn backwards whenn ConeConstraints are shipped
- ragdollJoint(character, character.UpperTorso, character.LeftUpperArm, "LeftShoulder", "BallSocket")
- ragdollJoint(character, character.LeftUpperArm, character.LeftLowerArm, "LeftElbow", "BallSocket")
- ragdollJoint(character, character.UpperTorso, character.RightUpperArm, "RightShoulder", "BallSocket")
- ragdollJoint(character, character.RightUpperArm, character.RightLowerArm, "RightElbow", "BallSocket")
- ragdollJoint(character, character.LowerTorso, character.LeftUpperLeg, "LeftHip", "BallSocket")
- ragdollJoint(character, character.LowerTorso, character.RightUpperLeg, "RightHip", "BallSocket")
- end
- end))
- if root then
- root.CanCollide = false
- end
- local c
- if root then
- c = root.Touched:Connect(function(obj)
- if obj and not obj:IsDescendantOf(junk) and (root.Velocity.Magnitude >= 2) then
- local impact = Instance.new("Sound")
- impact.Parent = root
- impact.Name = 'impact'
- impact.SoundId = 'rbxassetid://' .. impacts[math.random(1,#impacts)]
- impact.Volume = 0.1
- impact.PlayOnRemove = true
- impact:Destroy()
- end
- end)
- end
- local function restore()
- if c then
- c:Disconnect()
- end
- if root then
- root.CFrame = root.CFrame*CFrame.new(0,4,0)
- end
- for i,v in pairs(js) do
- v:Destroy()
- end
- for i,v in pairs(lc) do
- for i,v in pairs(v) do
- v:Destroy()
- end
- end
- if targhum then
- targhum.PlatformStand = false
- end
- for i,v in pairs(js2) do
- v.obj.Parent = v.par
- end
- if root then
- root.CanCollide = true
- end
- end
- return restore
- end
- local t = Instance.new("Tool")
- t.CanBeDropped = false
- local Part1 = Instance.new("Part")
- local Sound6 = Instance.new("Sound")
- t.Name = "Impostor Tool"
- t.TextureId = "rbxassetid://5701818647"
- t.Grip = CFrame.new(0, 0, -1.5, 0, 0, 1, 1, 0, 0, 0, 1, 0)
- t.GripForward = Vector3.new(-1, -0, -0)
- t.GripPos = Vector3.new(0, 0, -1.5)
- t.GripRight = Vector3.new(0, 1, 0)
- t.GripUp = Vector3.new(0, 0, 1)
- Part1.Name = "Handle"
- Part1.Parent = t
- 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)
- Part1.Orientation = Vector3.new(-46.2400017, 42.1399994, 50.9300003)
- Part1.Position = Vector3.new(214.957138, 4.28734684, -190.317474)
- Part1.Rotation = Vector3.new(-54.6199989, 27.6499996, 84.0999985)
- Part1.Color = Color3.new(0.388235, 0.372549, 0.384314)
- Part1.Size = Vector3.new()
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.BrickColor = BrickColor.new("Dark stone grey")
- Part1.Locked = true
- Part1.Transparency = 1
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.brickColor = BrickColor.new("Dark stone grey")
- Part1.FormFactor = Enum.FormFactor.Plate
- Part1.formFactor = Enum.FormFactor.Plate
- Sound6.Name = "Kill"
- Sound6.Parent = nil
- Sound6.SoundId = "rbxassetid://5700183626"
- Sound6.Volume = 2
- plr = owner
- local Tool = t
- local Handle = Tool:WaitForChild("Handle")
- Tool.Parent = plr['Backpack']
- local tag = Instance.new("ObjectValue")
- tag.Name = 'par'
- tag.Value = plr['Backpack']
- tag.Parent = t
- local char = plr.Character
- local hum = char:FindFirstChildOfClass("Humanoid")
- local root = char:FindFirstChild("HumanoidRootPart")
- local Players = game:GetService("Players")
- local Debris = game:GetService("Debris")
- local Sounds = {
- Kill = Sound6,
- }
- local function CheckIfAlive()
- 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)
- end
- local can_kill = true
- local kill_cooldown = 1
- local kill_distance = 10
- local function kill(Hit,dist)
- if not Hit or not Hit.Parent or not CheckIfAlive() then
- return
- end
- local character = Hit.Parent
- if character == char then
- return
- end
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if not humanoid or humanoid.Health == 0 then
- return
- end
- local player = Players:GetPlayerFromCharacter(character)
- if player and ((player == plr)) then
- return
- end
- if can_kill then
- local sp = Instance.new("Part")
- sp.Size = Vector3.new()
- sp.Transparency = 1
- sp.CanCollide = false
- sp.Anchored = true
- sp.Locked = true
- sp.Position = root.Position
- sp.Parent = script
- local s1 = Sounds.Kill:Clone()
- s1.Parent = sp
- s1:Play()
- local s2 = Sounds.Kill:Clone()
- s2.SoundId = 'rbxassetid://6484812516'
- s2.Parent = sp
- s2:Play()
- spawn(function()
- root.Anchored = true
- local sv = root.Velocity
- local trans = {}
- for i,v in pairs(char:GetDescendants()) do
- if (v:IsA("BasePart") or v:IsA("UnionOperation")) and 0 >= v.Transparency then
- trans[v] = true
- game:GetService("TweenService"):Create(v,TweenInfo.new(0.1),{Transparency = 1}):Play()
- end
- end
- game:GetService("TweenService"):Create(root,TweenInfo.new(0.1),{CFrame = Hit.CFrame}):Play()
- humanoid:TakeDamage(1/0)
- wait(0.1)
- for i,v in pairs(trans) do
- game:GetService("TweenService"):Create(i,TweenInfo.new(0.1),{Transparency = 0}):Play()
- end
- root.Anchored = false
- root.Velocity = sv
- local tempkillval = Instance.new("ObjectValue")
- tempkillval.Name = 'killer'
- tempkillval.Value = nil -- plr
- tempkillval.Parent = humanoid
- humanoid:TakeDamage(1/0)
- local ragval = Instance.new("ObjectValue")
- ragval.Name = 'Ragdolled'
- ragval.Parent = humanoid
- humanoid.AutoRotate = false
- humanoid.PlatformStand = true
- ragdoll(character,true)
- end)
- spawn(function()
- can_kill = false
- Tool.Parent = nil
- wait(kill_cooldown)
- if not char or not hum or not root or 0 >= hum.Health then
- repeat
- wait(1)
- char = plr.Character
- hum = char:FindFirstChildOfClass("Humanoid")
- root = char:FindFirstChild("HumanoidRootPart")
- until char and hum and root and hum.Health > 0
- end
- Tool.Parent = plr['Backpack']
- can_kill = true
- end)
- end
- end
- local function get_near()
- local dist = kill_distance
- local near = nil
- for i,v in pairs(workspace:GetChildren()) do
- if v ~= char then else continue end
- local tc = v
- local tt = nil
- local th = nil
- pcall(function()
- tt = tc:FindFirstChild("HumanoidRootPart") or tc:FindFirstChild("Torso") or tc:FindFirstChild("Head")
- end)
- pcall(function()
- th = tc:FindFirstChildOfClass("Humanoid")
- end)
- if tc and tt and th and th.Health > 0 then
- local cdi = (tt.Position-root.Position).Magnitude
- if dist >= cdi then
- dist = cdi
- near = tt
- end
- end
- end
- return near,dist
- end
- Tool.Equipped:Connect(function()
- local near,dist = get_near()
- if not near then
- wait(0)
- if not can_kill then
- Tool.Parent = nil
- else
- if not char or not hum or not root or 0 >= hum.Health then
- repeat
- wait(1)
- char = plr.Character
- hum = char:FindFirstChildOfClass("Humanoid")
- root = char:FindFirstChild("HumanoidRootPart")
- until char and hum and root and hum.Health > 0
- end
- Tool.Parent = plr['Backpack']
- end
- else
- kill(near)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement