So i have this server-sided ragdoll script:
function module.Ragdoll(character:Model, ragdollmiktari)
if character:GetAttribute("Ragdolled") == true then return end
local hum = character:FindFirstChild("Humanoid")::Humanoid
if not hum then return end
if character:HasTag("PlayerChar") then
RagdollRemote:FireClient(ps:GetPlayerFromCharacter(character), ragdollmiktari) --for ui handling
end
for i, joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = false
elseif joint:IsA("BasePart") and joint.Name == "Collide" then
joint.CanCollide = true
elseif joint:IsA("BallSocketConstraint") then
joint.Enabled = true
end
end
hum.PlatformStand = true
hum.AutoRotate = false
character:SetAttribute("Ragdolled", true)
hum:UnequipTools()
UnequipConnections[character] = character.ChildAdded:Connect(function(child)
hum:UnequipTools() --for unequiping tools, obviously
end)
end
function module.UnRagdoll(character:Model)
local hum = character:FindFirstChild("Humanoid")::Humanoid
if not hum then return end
if UnequipConnections[character] then
UnequipConnections[character]:Disconnect()
UnequipConnections[character] = nil
end
character:SetAttribute("Ragdolled", false)
for i, joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
joint.Enabled = true
elseif joint:IsA("BallSocketConstraint") then
joint.Enabled = false
elseif joint:IsA("BasePart") and joint.Name == "Collide" then
joint.CanCollide = false
end
end
hum.PlatformStand = false
hum.AutoRotate = true
end
And this script for set up. Its being called on CharacterAdded event + when dummies are created:
function module.BuildCollisionParts(char: Model)
for _, v in pairs(char:GetChildren()) do
if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
local p = Instance.new("Part")
p.Size = v.Size
p.CFrame = v.CFrame
p.Anchored = false
p.CanCollide = false
p.Massless = true
p.Transparency = 1
p.Name = "Collide"
p.Parent = char
local weld = Instance.new("WeldConstraint")
weld.Part0 = v
weld.Part1 = p
weld.Parent = p
end
end
end
for i, joint in pairs(char:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
if joint.Name == "Neck" then
print("thats a neck")
socket.Name = "BallSocketConstraintHead"
end
local att0 = Instance.new("Attachment", joint.Part0)
local att1 = Instance.new("Attachment", joint.Part1)
att0.CFrame = joint.C0
att1.CFrame = joint.C1
att0.Name = "att0"
att1.Name = "att1"
socket.Attachment0 = att0
socket.Attachment1 = att1
socket.TwistLimitsEnabled = true
socket.LimitsEnabled = true
socket.UpperAngle = 45
socket.TwistLowerAngle = -30
socket.TwistUpperAngle = 30
socket.Enabled = false
socket.Parent = joint.Parent
end
end
On a server script:
RagdollModule.UnRagdoll(char)
Arms:
Unragdolling: (it doesnt always happen)
Do anyone knows how do i fix these?
