I am trying to replicated TSBG’s ragdoll system
Here is the code
local module = {}
local RunService = game:GetService("RunService")
-- local HttpService = game:GetService("HttpService")
-- local PhysicsService = game:GetService("PhysicsService")
function module.Start(Rig : Model)
module[Rig] = {
Collision = {},
Properties = {},
-- ID = HttpService:GenerateGUID(false)
} -- create 5
local Humanoid = Rig:FindFirstChildWhichIsA("Humanoid")
-- local ID = module[Rig].ID
-- PhysicsService:RegisterCollisionGroup(ID)
-- PhysicsService:CollisionGroupSetCollidable(ID, ID, false)
for _, Descendant in Rig:GetDescendants() do
if Descendant:IsA("Motor6D") then
local Socket = Instance.new("BallSocketConstraint")
local Attachment0 = Instance.new("Attachment")
local Attachment1 = Instance.new("Attachment")
Attachment0.CFrame = Descendant.C0
Attachment1.CFrame = Descendant.C1
Attachment0.Parent = Descendant.Part0
Attachment1.Parent = Descendant.Part1
Socket.Attachment0 = Attachment0
Socket.Attachment1 = Attachment1
Socket.LimitsEnabled, Socket.TwistLimitsEnabled = true, true
Socket.UpperAngle = 0
Socket.MaxFrictionTorque = 10
Socket.TwistLowerAngle = -25
Socket.TwistUpperAngle = 25
Socket.Parent = Descendant.Parent
Descendant.Enabled = false
elseif Descendant:IsA("BasePart") then
module[Rig].Collision[Descendant] = Descendant.CanCollide
print(Descendant.CollisionGroup)
-- Descendant.CollisionGroup = ID
module[Rig].Connection = RunService.Heartbeat:Connect(function()
Descendant.CanCollide = true
end)
end
end
local Properties = {
PlatformStand = true,
AutoRotate = false,
WalkSpeed = 0,
JumpPower = 0,
JumpHeight = 0
}
for name, value in Properties do
module[Rig].Properties[name] = Humanoid[name]
Humanoid[name] = value
end
end
function module.Stop(Rig : Model)
local selected = module[Rig]
if module[Rig] then
local Properties = selected.Properties
local Collision = selected.Collision
local Connection = selected.Connection
local ID = selected.ID
-- PhysicsService:UnregisterCollisionGroup(ID)
if Connection then
Connection:Disconnect()
end
local Humanoid = Rig:FindFirstChildWhichIsA("Humanoid")
for name, value in Properties do
Humanoid[name] = value
end
for _, Descendant in Rig:GetDescendants() do
if Descendant:IsA("BallSocketConstraint") then
Descendant:Destroy()
elseif Descendant:IsA("Motor6D") then
Descendant.Enabled = true
elseif Descendant:IsA("BasePart") then
Descendant.CanCollide = Collision[Descendant]
-- Descendant.CollisionGroup = nil
end
end
module[Rig] = nil
end
end
return module
I want it to ragdoll the person and make the limbs (besides the torso - like i want the arms to collide with the torso) not collidable with each other, but collidable with the rest of the objects in the game
The commented out code is what I tried, but it doesn’t work
Both commented and uncommented code result in this
See how the legs are going through the map, and the arms are not collidable with the torso? But when I knock the guy over, it kinda works
The TSB ragdoll is what I want it to look like
How do I fix this?
And maybe just me but I think the head is not ragdolling either