DrakerMaker

Ragdoll R6

Sep 2nd, 2019
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. game.Players.PlayerAdded:connect(function(plr)
  2. plr.CharacterAdded:connect(function()
  3. Character=plr.Character
  4.  
  5. local leftarm = Character:FindFirstChild("Left Arm")
  6. local leftleg = Character:FindFirstChild("Left Leg")
  7. local rightleg = Character:FindFirstChild("Right Leg")
  8. local rightarm = Character:FindFirstChild("Right Arm")
  9. local torso = Character:FindFirstChild("Torso")
  10. local head = Character:FindFirstChild("Head")
  11. local root = Character:FindFirstChild("HumanoidRootPart")
  12.  
  13. local HeadA = Instance.new("Attachment")
  14. HeadA.Name = "HeadA"
  15. HeadA.Parent = head
  16. HeadA.Position = Vector3.new(0, -0.5, 0)
  17. HeadA.Rotation = Vector3.new(0, 0, -0)
  18. HeadA.Axis = Vector3.new(1, -0, -0)
  19. HeadA.SecondaryAxis = Vector3.new(0, 1, 0)
  20.  
  21. local LeftArmA = Instance.new("Attachment")
  22. LeftArmA.Name = "LeftArmA"
  23. LeftArmA.Parent = leftarm
  24. LeftArmA.Position = Vector3.new(0.4, 0.8, 0)
  25. LeftArmA.Rotation = Vector3.new(-180, 0, 90)
  26. LeftArmA.Axis = Vector3.new(0, -1, -0)
  27. LeftArmA.SecondaryAxis = Vector3.new(-1, 0, 0)
  28.  
  29. local LeftLegA = Instance.new("Attachment")
  30. LeftLegA.Name = "LeftLegA"
  31. LeftLegA.Parent = leftleg
  32. LeftLegA.Position = Vector3.new(0, 1, 0)
  33. LeftLegA.Rotation = Vector3.new(90, -90, 0)
  34. LeftLegA.Axis = Vector3.new(0, -1, -0)
  35. LeftLegA.SecondaryAxis = Vector3.new(0, -0, 1)
  36.  
  37. local RightArmA = Instance.new("Attachment")
  38. RightArmA.Name = "RightArmA"
  39. RightArmA.Parent = rightarm
  40. RightArmA.Position = Vector3.new(-0.4, 0.8, 0)--Vector3.new(0, 1, 0)
  41. RightArmA.Rotation = Vector3.new(-180, 0, 90)--Vector3.new(90, -90, 0)
  42. RightArmA.Axis = Vector3.new(0, -1, -0)--Vector3.new(0, -1, -0)
  43. RightArmA.SecondaryAxis = Vector3.new(0, 1, 0)--Vector3.new(0, -0, 1)
  44.  
  45. local RightLegA = Instance.new("Attachment")
  46. RightLegA.Name = "RightLegA"
  47. RightLegA.Parent = rightleg
  48. RightLegA.Position = Vector3.new(0, 1, 0) --Vector3.new(-0.4, 0.8, 0)
  49. RightLegA.Rotation = Vector3.new(90, -90, 0)--Vector3.new(-180, 0, 90)
  50. RightLegA.Axis = Vector3.new(0, -1, -0)--Vector3.new(0, -1, -0)
  51. RightLegA.SecondaryAxis = Vector3.new(0, -0, 1)--Vector3.new(0, 1, 0)
  52.  
  53. local TorsoA = Instance.new("Attachment")
  54. TorsoA.Name = "TorsoA"
  55. TorsoA.Parent = torso
  56. TorsoA.Position = Vector3.new(0.5, -1.1, 0)
  57. TorsoA.Rotation = Vector3.new(90, -90, 0)
  58. TorsoA.Axis = Vector3.new(0, -1, -0)
  59. TorsoA.SecondaryAxis = Vector3.new(0, -0, 1)
  60.  
  61. local TorsoA1 = Instance.new("Attachment")
  62. TorsoA1.Name = "TorsoA1"
  63. TorsoA1.Parent = torso
  64. TorsoA1.Position = Vector3.new(-0.5, -1.1, 0)
  65. TorsoA1.Rotation = Vector3.new(90, -90, 0)
  66. TorsoA1.Axis = Vector3.new(0, -1, -0)
  67. TorsoA1.SecondaryAxis = Vector3.new(0, -0, 1)
  68.  
  69. local TorsoA2 = Instance.new("Attachment")
  70. TorsoA2.Name = "TorsoA2"
  71. TorsoA2.Parent = torso
  72. TorsoA2.Position = Vector3.new(-1, 0.8, 0)
  73. TorsoA2.Rotation = Vector3.new(0, 0, -180)
  74. TorsoA2.Axis = Vector3.new(-1, -0, 0)
  75. TorsoA2.SecondaryAxis = Vector3.new(0, -1, 0)
  76.  
  77. local TorsoA3 = Instance.new("Attachment")
  78. TorsoA3.Name = "TorsoA3"
  79. TorsoA3.Parent = torso
  80. TorsoA3.Position = Vector3.new(1, 0.8, 0)
  81. TorsoA3.Rotation = Vector3.new(-180, 0, 0)
  82. TorsoA3.Axis = Vector3.new(1, -0, 0)
  83. TorsoA3.SecondaryAxis = Vector3.new(-0, -1, -0)
  84.  
  85. local TorsoA4 = Instance.new("Attachment")
  86. TorsoA4.Name = "TorsoA4"
  87. TorsoA4.Parent = torso
  88. TorsoA4.Position = Vector3.new(0, 1, 0)
  89. TorsoA4.Rotation = Vector3.new(0, 0, -0)
  90. TorsoA4.Axis = Vector3.new(1, -0, 0)
  91. TorsoA4.SecondaryAxis = Vector3.new(0, 1, 0)
  92.  
  93. local TorsoA5 = Instance.new("Attachment")
  94. TorsoA5.Name = "TorsoA5"
  95. TorsoA5.Parent = torso
  96. TorsoA5.Position = Vector3.new(0, 0, 0)
  97. TorsoA5.Rotation = Vector3.new(0, 90, 0)
  98. TorsoA5.Axis = Vector3.new(0, 0, -1)
  99. TorsoA5.SecondaryAxis = Vector3.new(0, 1, 0)
  100.  
  101. local TorsoA6 = Instance.new("Attachment")
  102. TorsoA6.Name = "TorsoA6"
  103. TorsoA6.Parent = torso
  104. TorsoA6.Position = Vector3.new(0, 1, 0)
  105. TorsoA5.Rotation = Vector3.new(0, 0, 0)
  106. --TorsoA6.Axis = Vector3.new(0, 0, -1)
  107. --TorsoA6.SecondaryAxis = Vector3.new(0, 1, 0)
  108.  
  109.  
  110. local rootA = Instance.new("Attachment")
  111. rootA.Name= "rootA"
  112. rootA.Parent = root
  113. rootA.Position = Vector3.new(0, 0, 0)
  114. rootA.Rotation = Vector3.new(0, 90, 0)
  115. rootA.Axis = Vector3.new(0, 0, -1)
  116. rootA.SecondaryAxis = Vector3.new(0, 1, 0)
  117.  
  118.  
  119. local LAT = Instance.new("BallSocketConstraint")
  120. LAT.Parent = leftarm
  121. LAT.Attachment0 = LeftArmA
  122. LAT.Attachment1 = TorsoA2
  123. LAT.Enabled = true
  124.  
  125. local RAT = Instance.new("BallSocketConstraint")
  126. RAT.Parent = rightarm
  127. RAT.Attachment0 = RightArmA
  128. RAT.Attachment1 = TorsoA3
  129. RAT.Enabled = true
  130.  
  131. local TLL = Instance.new("BallSocketConstraint")
  132. TLL.Parent = torso
  133. TLL.Attachment0 = TorsoA1
  134. TLL.Attachment1 = LeftLegA
  135. TLL.Enabled = true
  136.  
  137. local TRL = Instance.new("BallSocketConstraint")
  138. TRL.Parent = torso
  139. TRL.Attachment0 = TorsoA
  140. TRL.Attachment1 = RightLegA
  141. TRL.Enabled = true
  142.  
  143. local RTA = Instance.new("BallSocketConstraint")
  144. RTA.Parent = root
  145. RTA.Attachment0 = rootA
  146. RTA.Attachment1 = TorsoA5
  147. RTA.Enabled = true
  148.  
  149. local Neck = Instance.new("BallSocketConstraint")
  150. Neck.Parent = torso
  151. Neck.Attachment0 = TorsoA6
  152. Neck.Attachment1 = HeadA
  153. Neck.Enabled = true
  154.  
  155. function getAttachment0(attachmentName)
  156. for _,child in next,Character:GetChildren() do
  157. local attachment = child:FindFirstChild(attachmentName)
  158. if attachment then
  159. return attachment
  160. end
  161. end
  162. end
  163.  
  164.  
  165. for _,child in next,Character:GetChildren() do
  166. if child:IsA("Accoutrement") then
  167. --Loop through all parts instead of only checking for one to be forwards-compatible in the event
  168. --ROBLOX implements multi-part accessories
  169. for _,part in next,child:GetChildren() do
  170. if part:IsA("BasePart") then
  171. local attachment1 = part:FindFirstChildOfClass("Attachment")
  172. local attachment0 = getAttachment0(attachment1.Name)
  173. if attachment0 and attachment1 then
  174. --Shouldn't use constraints for this, but have to because of a ROBLOX idiosyncrasy where
  175. --joints connecting a character are perpetually deleted while the character is dead
  176. local constraint = Instance.new("HingeConstraint")
  177. constraint.Attachment0 = attachment0
  178. constraint.Attachment1 = attachment1
  179. constraint.LimitsEnabled = true
  180. constraint.UpperAngle = 0 --Simulate weld by making it difficult for constraint to move
  181. constraint.LowerAngle = 0
  182. constraint.Parent = Character
  183. end
  184. end
  185. end
  186. end
  187. end
  188.  
  189.  
  190. end)
  191. end)
Advertisement
Add Comment
Please, Sign In to add comment