Hello, so I have a ragdoll system, when I ragdoll the player can move and the player acts all fishy, literally, here is an image:
I don’t want to use platformstand because then limbs fall through the map making it all weird, and if I turn on collisions the limbs get trapped through the floor:
I tried different things such as Setting the humanoid state to Physics, Ragdoll, and FallingDown
as well as disabling the enabled state of GettingUp, Jumping, and Seated
yet none of it ragdolls the player in a way that character cannot move by user input, and making the humanoid lay on the floor due to ragdoll.
CODE:
function ToggleRagdollPlayer(Player: Player, Enable: boolean)
if not Player then return end
if not Player.Character then return end
local Humanoid: Humanoid = Player.Character:WaitForChild("Humanoid")
local Motor6Ds = {
["Left Hip"] = "Left Leg",
["Right Hip"] = "Right Leg",
["Neck"] = "Head",
["Right Shoulder"] = "Right Arm",
["Left Shoulder"] = "Left Arm"
}
-- Loop Through each limb.
for _, Part in pairs(Player.Character:GetChildren()) do
if not Part:IsA("BasePart") then continue end
local PartMotorName = FindIndexByValue(Motor6Ds, Part.Name)
if PartMotorName == nil then continue end
local Motor6D: Motor6D = Player.Character:WaitForChild("Torso"):FindFirstChild(PartMotorName)
local Attachment0: Attachment
local Attachment1: Attachment
local BallSocket: BallSocketConstraint
local PreviousPartAttachment = Part:FindFirstChild(Part.Name)
if PreviousPartAttachment ~= nil and PreviousPartAttachment:IsA("Attachment") then
Attachment1 = PreviousPartAttachment
else
Attachment1 = Instance.new("Attachment")
Attachment1.Name = Part.Name
Attachment1.Parent = Part
Attachment1.CFrame = Motor6D.C1
end
local PreviousTorsoAttachment = Player.Character:WaitForChild("Torso"):FindFirstChild(Part.Name)
if PreviousTorsoAttachment ~= nil and PreviousTorsoAttachment:IsA("Attachment") then
Attachment0 = PreviousTorsoAttachment
else
Attachment0 = Instance.new("Attachment")
Attachment0.Name = Part.Name
Attachment0.Parent = Player.Character:WaitForChild("Torso")
Attachment0.CFrame = Motor6D.C0
end
local PreviousBallSocket = Player.Character:WaitForChild("Torso"):FindFirstChild(Part.Name.." Ragdoll")
if PreviousBallSocket ~= nil and PreviousBallSocket:IsA("BallSocketConstraint") then
BallSocket = PreviousBallSocket
else
BallSocket = Instance.new("BallSocketConstraint")
BallSocket.Name = Part.Name.." Ragdoll"
BallSocket.Parent = Player.Character:WaitForChild("Torso")
BallSocket.Attachment0 = Attachment0
BallSocket.Attachment1 = Attachment1
BallSocket.LimitsEnabled = true
BallSocket.Enabled = false
BallSocket.TwistLimitsEnabled = true
end
if Enable == true then
BallSocket.Enabled = true
Motor6D.Enabled = false
else
Motor6D.Enabled = true
BallSocket.Enabled = false
end
end
if Enable == true then
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
if Humanoid.Health > 0 then
Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
end
Humanoid.WalkSpeed = 0
--Humanoid.PlatformStand = true
else
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Seated, true)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
if Humanoid.Health > 0 then
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
Humanoid.PlatformStand = false
Humanoid.WalkSpeed = 16
end
end