So currently I have this ragdoll module script right here in startercharacterscripts:
local module = {}
local Humanoid = script.Parent:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false
function module:Ragdoll()
for index,joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
print(joint.Parent)
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp, false)
Humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
Humanoid.WalkSpeed = 0
end
end
end
function module:Unragdoll()
for index,joint in pairs(script.Parent:GetDescendants()) do
if joint:IsA("Motor6D") then
if joint.Parent:FindFirstChild("Attachment") and joint.Parent:FindFirstChild("Attachment").Name == "Attachment" then
joint.Parent:FindFirstChild("Attachment"):Destroy()
if joint.Parent:FindFirstChildOfClass("BallSocketConstraint") then
joint.Parent:FindFirstChildOfClass("BallSocketConstraint"):Destroy()
if joint.Enabled == false then joint.Enabled = true end
Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
Humanoid.WalkSpeed = 16
end
end
end
end
end
return module
And when I reset, the ragdoll works and I fall down. But when I call the Ragdoll function in a script when the player joins, they get ragdolled but doesn’t fall down, so how can I fix this?
(what I mean when they get ragdolled upon joining like in a game you hit someone and they get ragdolled for a couple of seconds)
Script:
wait(2)
local module = require(script.Parent.Ragdoll)
module.Ragdoll()