local PLRs = game:GetService("Players")
PLRs.PlayerAdded:Connect(function(char)
char.CharacterAdded:Connect(function(char)
local Humanoid:Humanoid = char:WaitForChild("Humanoid")
Humanoid.BreakJointsOnDeath = false
Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
Humanoid.HealthDisplayType = Enum.HumanoidHealthDisplayType.AlwaysOff
local IsRagdolled = Instance.new("BoolValue")
IsRagdolled.Name = "IsRagdolled"
IsRagdolled.Parent = char
IsRagdolled.Value = false
-- Ragdoll System
local function Ragdoll()
for i, Limb in pairs(char:GetDescendants()) do
if Limb:IsA("Motor6D") then
Humanoid.PlatformStand = true
local At0, At1 = Instance.new("Attachment"), Instance.new("Attachment")
At0.Parent = Limb.Part0
At1.Parent = Limb.Part1
At0.CFrame = Limb.C0
At1.CFrame = Limb.C1
local BSC = Instance.new("BallSocketConstraint")
BSC.Parent = Limb.Part0
BSC.Attachment0 = At0
BSC.Attachment1 = At1
if Limb.Parent.Name == "Head" then
BSC.LimitsEnabled = true
BSC.TwistLimitsEnabled = true
BSC.UpperAngle = 45
BSC.TwistLowerAngle = -75
BSC.TwistUpperAngle = 45
else
BSC.LimitsEnabled = true
BSC.TwistLimitsEnabled = true
BSC.UpperAngle = 10
end
if Limb.Parent.Name == "HumanoidRootPart" then
task.wait()
Limb.Parent.CanCollide = false
elseif Limb.Parent.Name ~= "HumanoidRootPart" then
task.wait()
Limb.Parent.CanCollide = true
end
Limb.Enabled = false
end
end
end
local function UnRagdoll()
local SelectedLimb = {
"HumanoidRootPart",
"Upper Torso",
"Lower Torso",
}
for i, Limb in pairs(char:GetDescendants()) do
if Limb:IsA("Motor6D") then
Humanoid.PlatformStand = false
Limb.Enabled = true
end
if Limb:IsA("BallSocketConstraint") then
Limb:Destroy()
end
if Limb.Name == "Attachment" then
Limb:Destroy()
end
for i, Collide in pairs(char:GetDescendants()) do
if Collide:IsA("BasePart") and Collide.Name ~= SelectedLimb[i] then
Collide.CanCollide = false
elseif Collide:IsA("BasePart") and Collide.Name == SelectedLimb[i] then
Collide.CanCollide = true
end
end
end
end
IsRagdolled:GetPropertyChangedSignal("Value"):Connect(function()
if IsRagdolled.Value == true then
Ragdoll()
else
UnRagdoll()
end
end)
-- Die Effect
Humanoid.Died:Connect(function()
IsRagdolled.Value = true
end)
end)
end)
I was making a game that uses ragdoll system but strangely The limb get collide turn on except HRP (HumanoidRootPart) which is wont uncollide even though i put:
if Limb.Parent.Name == "HumanoidRootPart" then
task.wait()
Limb.Parent.CanCollide = false
elseif Limb.Parent.Name ~= "HumanoidRootPart" then
task.wait()
Limb.Parent.CanCollide = true
end
ive tried putting Else and it did not work, so please how do i uncollide HRP (HumanoidRootPart)