Advertisement
Dalebig

Ragdoll function

Jul 7th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. Activate = function(Humanoid)
  2.     local Folder = Instance.new("Folder")
  3.     local Weld = Instance.new("WeldConstraint")
  4.    
  5.     Humanoid.BreakJointsOnDeath = false
  6.     Humanoid.RequiresNeck = false
  7.     Humanoid.PlatformStand = true
  8.     Humanoid.Parent.HumanoidRootPart.CanCollide = false
  9.     Humanoid.Parent.HumanoidRootPart.Massless = true
  10.    
  11.     Folder.Name = "Rig_Parts"
  12.     Folder.Parent = Humanoid
  13.     Weld.Name = "Root_Anchor"
  14.     Weld.Part0 = Humanoid.Parent.HumanoidRootPart
  15.     Weld.Part1 = Humanoid.Parent.LowerTorso
  16.     Weld.Parent = Humanoid
  17.  
  18.     for i,State in pairs(Enum.HumanoidStateType:GetEnumItems()) do
  19.         if State ~= Enum.HumanoidStateType.PlatformStanding and State ~= Enum.HumanoidStateType.Dead and State ~= Enum.HumanoidStateType.None then
  20.             Humanoid:SetStateEnabled(State,false)
  21.         end
  22.     end
  23.     for i,Object in pairs(Humanoid.Parent:GetChildren()) do
  24.         if Object:IsA("BasePart") and Object:FindFirstChildOfClass("Motor6D") then
  25.             local Joint = Object:FindFirstChildOfClass("Motor6D")
  26.             local NoCollision = Instance.new("NoCollisionConstraint")
  27.             local BallSocket = Instance.new("BallSocketConstraint")
  28.            
  29.             NoCollision.Name = Object.Name.."_Constraint"
  30.             NoCollision.Part0 = Joint.Part0
  31.             NoCollision.Part1 = Joint.Part1
  32.             NoCollision.Parent = Humanoid
  33.            
  34.             BallSocket.Name = Object.Name.."_Weld"
  35.             BallSocket.Parent = Humanoid
  36.         end
  37.     end
  38.     for i,Object in pairs(Humanoid.Parent:GetChildren()) do
  39.         if Object:IsA("BasePart") and Object:FindFirstChildOfClass("Motor6D") then
  40.             local Joint = Object:FindFirstChildOfClass("Motor6D")
  41.             local BallSocket = Humanoid[Object.Name.."_Weld"]
  42.             if Joint.Part0:FindFirstChild(Joint.Name.."RigAttachment") then
  43.                 BallSocket.Attachment0 = Joint.Part0[Joint.Name.."RigAttachment"]
  44.             end
  45.             BallSocket.Attachment1 = Joint.Part1[Joint.Name.."RigAttachment"]
  46.             BallSocket.Radius = 0.5
  47.             BallSocket.LimitsEnabled = true
  48.             BallSocket.TwistLimitsEnabled = true
  49.             BallSocket.Restitution = 0.5
  50.             Joint.Enabled = false
  51.             if not Object.CanCollide then
  52.                 Object.Parent = Folder
  53.                 Object.CanCollide = true
  54.             end
  55.         end
  56.     end
  57.     Humanoid.PlatformStand = true
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement