Hey! I've been learning about terrain generation lately and I finally got my script to work, and then I had the thought of making a physics game, anyway, I need ragdolls for that, and I'm not really good with joints, so help is appreciated!
My script is:
01 | function ragdoll(player) |
02 | local plr = game.Players [ player ] |
03 | local character = plr.Character |
04 | for _,motor in pairs (character:GetDescendants()) do |
05 | if motor:IsA( "Motor6D" ) then |
06 | local at 1 , at 2 = Instance.new( "Attachment" , motor.Parent), Instance.new( "Attachment" , motor.Parent) |
07 | at 1. Name = "one" |
08 | at 2. Name = "two" |
09 |
10 |
11 | at 1. CFrame = motor.Part 0. CFrame |
12 | at 2. CFrame = motor.Part 1. CFrame |
13 | wait() |
14 | local joint = Instance.new( "BallSocketConstraint" , motor.Parent) |
15 | joint.Attachment 0 = at 1 |
Now, it is making ball joints, but they just float above my character and do nothing, they actually make my character fall apart?
Like I said help is appreciated, Thank you!
Here is a fixed version of your script that so far works for R15 (does some weird body poses LOL)
01 | local function ragdoll(player) |
02 | local character = player.Character or player.CharacterAdded:Wait() |
03 | local humanoid = character.Humanoid or player.CharacterAdded:Wait() |
04 | humanoid.BreakJointsOnDeath = false |
05 | humanoid.Died:Connect( function () |
06 | for i,motor in pairs (character:GetDescendants()) do |
07 | if motor:IsA( "Motor6D" ) then |
08 | local ballsocket = Instance.new( "BallSocketConstraint" ,motor.Parent) |
09 | local at 1 = motor.Part 0 :FindFirstChild(motor.Name.. "Attachment" ) or motor.Part 0 :FindFirstChild(motor.Name.. "RigAttachment" ) |
10 | local at 2 = motor.Part 1 :FindFirstChild(motor.Name.. "Attachment" ) or motor.Part 1 :FindFirstChild(motor.Name.. "RigAttachment" ) |
11 | ballsocket.Attachment 0 ,ballsocket.Attachment 1 = at 1 ,at 2 |
12 | motor:Destroy() |
13 | ballsocket.Visible = true |
14 | end |
15 | end |