Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local junk = workspace:FindFirstChild('junk') or workspace
- function limb_collide(obj,mode,d)
- if (obj:IsA("UnionOperation") or 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
- 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 ragdoll(targchar,kill,remove)
- local targplr
- pcall(function()
- targplr = game:GetService("Players"):GetPlayerFromCharacter(targchar)
- end)
- local pc = targchar
- local targhum = pc:FindFirstChild("Humanoid")
- local js,js2 = {},{}
- 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 then
- limb_collide(v,true,10)
- end
- end
- 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
- if remove then
- for i,v in pairs(old_pc:GetDescendants()) do
- if v:IsA("BasePart") or v:IsA("UnionOperation") 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 targtorso = pc:FindFirstChild("Torso") or pc:FindFirstChild("UpperTorso") or pc:FindFirstChild("Head") or pc:FindFirstChild("HumanoidRootPart")
- 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)
- local ragval = Instance.new("ObjectValue")
- ragval.Name = 'Ragdolled'
- ragval.Parent = targhum
- spawn(function()
- for _,m in pairs(pc:GetChildren()) do
- for _,v in pairs(m:GetChildren()) do
- if v:IsA("Snap") or v:IsA('Weld') then
- v:Destroy()
- end
- if (v:IsA('Motor6D') or v:IsA('Motor')) and v.Parent:IsA("Part") 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
- v.Parent = nil
- table.insert(js,1,b)
- end
- end
- end
- end)
- pcall(function()
- pc.HumanoidRootPart.CanCollide = false
- end)
- return js,js2
- end
- function hook(char)
- if char then else return end
- repeat wait() until char:FindFirstChildOfClass("Humanoid")
- local hum = char:FindFirstChildOfClass("Humanoid")
- hum.BreakJointsOnDeath = false
- hum.Died:Connect(function()
- hum.BreakJointsOnDeath = false
- local tempkillval = Instance.new("ObjectValue")
- tempkillval.Name = 'killer'
- tempkillval.Value = nil -- plr
- tempkillval.Parent = hum
- hum:TakeDamage(1/0)
- pcall(function()
- ragdoll(char,true)
- end)
- end)
- end
- for i,plr in pairs(game:GetService("Players"):GetPlayers()) do
- hook(plr.Character)
- plr.CharacterAdded:Connect(hook)
- end
- game:GetService("Players").PlayerAdded:Connect(function(plr)
- plr.CharacterAdded:Connect(hook)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement