Okay, I can help enhance the ragdoll script to achieve a more realistic standing pose with separated legs and bent knees. Implementing true dynamic foot planting based on terrain height is significantly more complex and often requires techniques like Inverse Kinematics (IK) or complex physics constraint manipulation (like AlignPosition/AlignOrientation driven by raycasts), which goes beyond simple BodyGyro adjustments.
However, we can simulate the appearance of bent knees and a wider stance using the existing BodyGyro approach by adjusting the target angles.
Here's the updated script incorporating these changes:
Key Changes:
Ragdoll) to prevent the character's own limbs from colliding with each other during ragdoll, which often improves stability.storeOriginalCollisions and restoreOriginalCollisions to properly save and restore CanCollide and CollisionGroupId settings when toggling ragdoll.BodyGyro instances for the UpperTorso and LowerTorso, focusing their torque on pitch/roll (X and Z axes) relative to the character's forward direction. Added a BodyForce specifically to the UpperTorso to help keep the upper body upright.legSpreadAngle): Added a Y-axis rotation to the BodyGyro CFrame for the upper and lower legs to make them spread outwards.kneeBendAngle): Added an X-axis rotation to the BodyGyro CFrame for the lower legs to simulate a bend at the knee.HumanoidRootPart's orientation (currentOrientation) when the standing forces are applied. This makes the standing pose align with the direction the character was facing.MaxTorque, P, and D values. These often require significant experimentation to get right for your specific character model and desired stability. Added small upward BodyForce to legs.BodyGyro targets for a slightly more relaxed pose instead of a strict T-pose.BodyGyro on the HumanoidRootPart as the torso gyros should now handle orientation. Kept the main upward BodyForce on the HRP, calculating it based on an approximation of the character's total mass.Motor6D joints correctly and slightly teleport the character upwards to avoid getting stuck.character.Destroying connection to clean up forces.Remember that achieving perfect, dynamically stable standing on any surface with just BodyMovers is very challenging. This script provides a good visual approximation of the desired pose. You'll likely need to fine-tune the P, D, MaxTorque, angle values, and BodyForce magnitudes further to get the exact behavior you want.
Okay, that error "Collision group not found" usually means the script tried to use PhysicsService:GetCollisionGroupId("Ragdoll") before the "Ragdoll" group was successfully created or registered by the service.
We can fix this by making the collision group creation more robust, ensuring it exists before we try to get its ID.
Here's the updated script with the fix:
Changes Made:
setupCollisionGroup() Function: Created a dedicated function to handle the creation and retrieval of the collision group ID (ragdollGroupId).pcall to safely check if the group exists. If not, it tries to create it (also within a pcall to catch errors). If creation fails, it warns the user and uses the default group ID (0) as a fallback.setupCollisionGroup() is called once when the script first runs to ensure the group is ready.makeRagdoll() just to be absolutely sure the ragdollGroupId variable is correctly set before being used in the loop.part.CollisionGroupId = ragdollGroupId is only assigned if ragdollGroupId is not 0 (meaning the group was successfully found or created).This should prevent the "Collision group not found" error by ensuring the script correctly handles the existence and creation of the collision group.