I wanted to make a cart, that player can push, the way I imagined it to work, is by ragdolling the players arms, or replacing them with other parts, attached to players body by either hinge constraint or ball socket.
Thought of something like this for an R6 character:
I however don’t know how I would do that. I think I have heard of Motor6D but I never worked with it before. Any ideas how I would make something like that?
Most ragdolls are done by turning Motor6Ds into ball socket joints, so to do it on only part of the character, you would only do that on specific Motor6Ds.
I would recommend you look at the code of some ragdoll scripts and reference them from there.
I had a similar situation where I needed a hand to stay on a specific part and I used Inverse Kinematics to achieve it. They work for pretty much any avatar type (e.g. R6 or R15) and you can use constraints to limit how much an arm can move to avoid unrealistic arm positions.
Have a look at the documentation for it and follow the example there to understand it a bit better. I haven’t used it much but feel free to ask if you need any help with it.
I’ve read through the documentation, and I’m not quite sure its the thing I need. These Inverse Kinematics seem great, but with the given examples for R15. I don’t find “realistic behavior” fitting for R6 rig. The original idea of adding a few hinge constraints to arms seems much more appealing to me, but I don’t know how I would get the parts of a player’s character.
There are only five joints/Motor6D’s that each attach from a separate limb to the torso, which are called: Left Hip, Left Shoulder, Right Shoulder, Right Hip, and Neck. You would also need to create new corresponding attachment(s) from any body part to any attachment parented by the torso. Set all new attachment CFrames the exact same as the old attachment CFrames. Disable the old attachments with the Motor6D’s and Enable the new attachments with the ball socket constraints. You can find each of the character joints by constructing a playerAdded event, taking the character instance by doing player.Character, and then the torso. Finding all five limbs’ attachments is the same way as finding a character torso’s Motor6D/attachments.
An example is provided below.
Client:
function replaceJoints()
Humanoid.AutoRotate = true --> Disabling AutoRotate prevents the Character rotating in first person or Shift-Lock
for _, motor: Motor6D in pairs(Character:GetDescendants()) do
if motor:IsA("Motor6D") then
if not attachmentCFrames[motor.Name] then return end
motor.Enabled = false;
local a0, a1 = Instance.new("Attachment"), Instance.new("Attachment")
a0.CFrame = attachmentCFrames[motor.Name][1]
a1.CFrame = attachmentCFrames[motor.Name][2]
a0.Name = "RagdollAttachment"
a1.Name = "RagdollAttachment"
createColliderPart(motor.Part1)
local b = Instance.new("BallSocketConstraint")
b.Attachment0 = a0
b.Attachment1 = a1
b.Name = "RagdollConstraint"
b.Radius = 0.15
b.LimitsEnabled = true
b.TwistLimitsEnabled = false
b.MaxFrictionTorque = 0
b.Restitution = 0
b.UpperAngle = 90
b.TwistLowerAngle = -45
b.TwistUpperAngle = 45
if motor.Name == "Neck" then
b.TwistLimitsEnabled = true
b.UpperAngle = 45
b.TwistLowerAngle = -70
b.TwistUpperAngle = 70
end
a0.Parent = motor.Part0
a1.Parent = motor.Part1
b.Parent = motor.Parent
end
end
end