Advertisement
Guest User

Ragdoll v2.0 (warning FD)

a guest
Jul 19th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. repeat wait() until workspace.CurrentCamera ~= nil
  2. script.Parent = game.Players.LocalPlayer.Character
  3. wait(0.001)
  4.  
  5. local cleanUpTime = 60 -- change this to whatever you want
  6.  
  7. local function NewHingePart()
  8. local B = Instance.new("Part")
  9. B.TopSurface = 0 B.BottomSurface = 0
  10. B.Shape = "Ball"
  11. B.Size = Vector3.new(1, 1, 1)
  12. B.Transparency = 1 B.CanCollide = true
  13. return B
  14. end
  15. local function CreateJoint(j_type, p0, p1, c0, c1)
  16. local nj = Instance.new(j_type)
  17. nj.Part0 = p0 nj.part1 = p1
  18. if c0 ~= nil then nj.C0 = c0 end
  19. if c1 ~= nil then nj.C1 = c1 end
  20. nj.Parent = p0
  21. end
  22.  
  23. local AttactmentData = { --Limb socket attaching to Torso
  24. --["AttachmentTag"] = {part_name, part_attachment, torso_attachment, relative_position}
  25. ["RA"] = {"Right Arm", CFrame.new(0, 0.5, 0), CFrame.new(1.5, 0.5, 0), CFrame.new(1.5, 0, 0)},
  26. ["LA"] = {"Left Arm", CFrame.new(0, 0.5, 0), CFrame.new(-1.5, 0.5, 0), CFrame.new(-1.5, 0, 0)},
  27. ["RL"] = {"Right Leg", CFrame.new(0, 0.5, 0), CFrame.new(0.5, -1.5, 0), CFrame.new(0.5, -2, 0)},
  28. ["LL"] = {"Left Leg", CFrame.new(0, 0.5, 0), CFrame.new(-0.5, -1.5, 0), CFrame.new(-0.5, -2, 0)},
  29. }
  30.  
  31. local collision_part = Instance.new("Part")
  32. collision_part.Name = "CP"
  33. collision_part.TopSurface = Enum.SurfaceType.Smooth
  34. collision_part.BottomSurface = Enum.SurfaceType.Smooth
  35. collision_part.Size = Vector3.new(1, 1.5, 1)
  36. collision_part.Transparency = 1
  37.  
  38. local camera = workspace.CurrentCamera
  39. local char = script.Parent
  40.  
  41. function RagdollV3()
  42. char.Archivable = true
  43. local ragdoll = char:clone()
  44. char.Archivable = false
  45.  
  46. local hdv = ragdoll:FindFirstChild("Head")
  47.  
  48. --Clears the real character from everything but humanoid
  49. for _, obj in pairs(char:GetChildren()) do
  50. if not obj:IsA("Humanoid") then
  51. obj:destroy()
  52. end
  53. end
  54.  
  55. --set up the ragdoll
  56. local function scan(ch)
  57. for i = 1, #ch do
  58. scan(ch[i]:GetChildren())
  59. if (ch[i]:IsA("ForceField") or ch[i].Name == "HumanoidRootPart") or ((ch[i]:IsA("Weld") or ch[i]:IsA("Motor6D")) and ch[i].Name ~= "HeadWeld" and ch[i].Name ~= "AttachementWeld") then
  60. ch[i]:destroy()
  61. end
  62. end
  63. end
  64. scan(ragdoll:GetChildren())
  65. local function scanc(ch)
  66. for _, obj in pairs(ch:GetChildren()) do
  67. scanc(obj)
  68. if obj:IsA("Script") or obj:IsA("LocalScript") or ((obj:IsA("Weld") or obj:IsA("Motor6D")) and obj.Name ~= "AttachementWeld") or obj:IsA("ForceField") or (obj:IsA("Snap") and obj.Parent.Name == "Torso")
  69. or obj:IsA("ParticleEmitter")then
  70. obj:destroy()
  71. elseif obj:IsA("BasePart") then
  72. obj.Velocity = Vector3.new(0, 0, 0)
  73. obj.RotVelocity = Vector3.new(0, 0, 0)
  74. if obj.Parent:IsA("Accessory") then
  75. obj.CanCollide = false
  76. end
  77. end
  78. end
  79. end
  80. scanc(ragdoll)
  81.  
  82. local f_head
  83.  
  84. local fhum = ragdoll:FindFirstChild("Humanoid")
  85. fhum.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
  86. fhum.PlatformStand = true
  87. fhum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
  88. fhum.Name = "RagdollHumanoid"
  89.  
  90. local Torso = ragdoll:FindFirstChild("Torso")
  91. if Torso then
  92. Torso.Velocity = Vector3.new(math.random(), 0.0000001, math.random()).unit * 5 + (Vector3.new(0, 0.15, 0))
  93. local Head = ragdoll:FindFirstChild("Head")
  94. if Head then
  95. camera.CameraSubject = Head
  96. CreateJoint("Weld", Torso, Head, CFrame.new(0, 1.5, 0))
  97. end
  98.  
  99. for att_tag, att_data in pairs(AttactmentData) do
  100. local get_limb = ragdoll:FindFirstChild(att_data[1])
  101. if get_limb ~= nil then
  102.  
  103. local att1 = Instance.new("Attachment")
  104. att1.Name = att_tag
  105. att1.CFrame = att_data[2]
  106. att1.Parent = get_limb
  107.  
  108. local att2 = Instance.new("Attachment")
  109. att2.Name = att_tag
  110. att2.CFrame = att_data[3]
  111. att2.Parent = Torso
  112.  
  113. local socket = Instance.new("BallSocketConstraint")
  114. socket.Name = att_tag .. "_SOCKET"
  115. socket.Attachment0 = att2
  116. socket.Attachment1 = att1
  117. socket.Radius = 0
  118. socket.Parent = Torso
  119.  
  120. get_limb.CanCollide = false
  121.  
  122. local cp = collision_part:Clone()
  123. local cp_weld = Instance.new("Weld")
  124. cp_weld.C0 = CFrame.new(0, -0.25, 0)
  125. cp_weld.Part0 = get_limb
  126. cp_weld.Part1 = cp
  127. cp_weld.Parent = cp
  128. cp.Parent = ragdoll
  129. end
  130. end
  131. end
  132. ragdoll.Parent = workspace
  133. game:GetService("Debris"):AddItem(ragdoll, cleanUpTime)
  134. fhum.MaxHealth = 100
  135. fhum.Health = fhum.MaxHealth
  136. end
  137.  
  138. char.Humanoid.Died:connect(RagdollV3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement