Advertisement
Guest User

Ragdoll v2.0 FE!

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