Advertisement
kareem11222

RAGEDOLL

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