how do i make characters parts collide when ragdolled (when not dead)
heres the script
function ragdoll.Start(character)
local orgSpeed = character.Humanoid.WalkSpeed
local orgJump = character.Humanoid.JumpPower
if character.Ragdolled.Value then return end
character.Ragdolled.Value = true
for i, joint in pairs(character:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a0 = Instance.new("Attachment")
local a1 = Instance.new("Attachment")
a0.Parent = joint.Part0
a1.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a0
socket.Attachment1 = a1
a0.CFrame = joint.C0
a1.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
end
end
character.Humanoid.WalkSpeed = 0
character.Humanoid.JumpPower = 0
character.Humanoid.PlatformStand = true
character.Humanoid.AutoRotate = false
end
function ragdoll.Stop(character)
local orgSpeed = character.Humanoid.WalkSpeed
local orgJump = character.Humanoid.JumpPower
local hrp = character:FindFirstChild("HumanoidRootPart")
local hum = character:FindFirstChild("Humanoid")
hum.PlatformStand = false
for i, joint in pairs(character:GetDescendants()) do
if joint:IsA("BallSocketConstraint") then
joint:Destroy()
end
if joint:IsA("Motor6D") then
joint.Enabled = true
end
end
character.Ragdolled.Value = false
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
hum.WalkSpeed = orgSpeed
hum.JumpPower = orgJump
hum.AutoRotate = true
end
return ragdoll
There are probably better methods out there, but the method I use is adding Parts and welding them to the character’s limbs with the same size and such. In my opinion, it’s kind of more controllable for me because I can resize them down a little if needed. Try doing parts.
if it works for you, thats. a glitch. The humanoid is supposed to constantly set the collision of limbs to false.
The easiest method is definitly to weld some parts on the limbs.
you could just use Instance.new() to create some parts, do some stuff to make it smaller would be optimal, and then attach them to the hand or lower arm/leg (or you could attach it to all of em)
Actually its not. Humanoids only set collision to false of parts that are a part attached with a motor 6d and a ball socket is well not a motor 6d therefore humanoid won’t be consistently settings its collision to true.
The method i use is setting the humanoidstatetype to Physics on the client whenever the player gets ragdolled. It should make limbs collide with stuff.
i know its outdated but, its prob because you set it to collide before setting the ball socket constraint, just as he said, it only sets to false if there is a motor 6d, i tried to put the collision after it and it worked, but a bit glitchy
When you ragdoll the player, set the player’s Collision Group to something else that doesn’t collide with anything, then loop through the player’s body parts and create a part in each one of them, welding them and turning the collision on.
Then you can create collision by using these functions.
local Character = Player.Character
local function SetCollision(CollisionGroup : string)
for _, v in pairs(Character:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroup = CollisionGroup
end
end
end
local function SetupHitbox(p : Part)
local Hitbox = Instance.new("Part")
Hitbox.Size = Vector3.new(2, 2, 2)
Hitbox.Name = p.Name.." Hitbox"
Hitbox.CanCollide = true
Hitbox.Anchored = false
local Weld = Instance.new("WeldConstraint")
Weld.Part0 = p
Weld.Part1 = Hitbox
Hitbox.Parent = p
Weld.Parent = Hitbox
end
local function DestroyHitboxes()
for _, v in pairs(Character:GetChildren()) do
if string.find(v.Name, "Hitbox") and v:IsA("Part") and v:FindFirstChildOfClass("WeldConstraint") then
v:Destroy()
end
end
end