Script Not Changing Can Collide on Character Limbs

  1. What do you want to achieve?
    For a character’s limbs to collide with everything else while inside of a ragdoll. I already have a script for the ragdolling.

  2. What is the issue?
    The script isn’t changing the “CanCollide” property inside of a character model.

  3. What solutions have you tried so far?
    I checked the Dev Hub, and the new Roblox Assistant, but I couldn’t find any answers.

Here is my script:

local Torso = script.Parent.Torso
script.Parent.Humanoid.RequiresNeck = false
script.Parent.Humanoid.PlatformStand = true

script.Parent["Right Arm"].CanCollide = true
script.Parent["Right Leg"].CanCollide = true
script.Parent["Left Arm"].CanCollide = true
script.Parent["Left Leg"].CanCollide = true
script.Parent.Head.CanCollide = true

for _, Object in ipairs(Torso:GetChildren()) do
	if Object:IsA("Motor6D") then
		Object.Enabled = false
	end
end

wait(1)

script.Parent.Humanoid.RequiresNeck = true
script.Parent.Humanoid.PlatformStand = false

script.Parent["Right Arm"].CanCollide = false
script.Parent["Right Leg"].CanCollide = false
script.Parent["Left Arm"].CanCollide = false
script.Parent["Left Leg"].CanCollide = false
script.Parent.Head.CanCollide = false

for _, Object in ipairs(Torso:GetChildren()) do
	if Object:IsA("Motor6D") then
		Object.Enabled = true
	end
end

Thanks in advance!

Are there any errors in the output? Adding a :WaitForChild() is better, as it waits for the children to load before.
script.Parent:WaitForChild("Left Leg").CanCollide = false

No errors.
And I have a wait function that waits for the torso.

Character limbs unfortunately cannot have their CanCollide property set to true because of how Humanoids act. However, you can get around this problem by creating an invisible part that is welded to each body part of the character.

local Character = script.Parent
local Torso = script.Parent.Torso
local HumanoidRootPart = script.Parent.HumanoidRootPart

for _,Objects in pairs (Character:GetChildren()) do
	if not Objects:IsA("BasePart") or Objects.CanCollide then
		continue
	end
	
	if Objects == Torso or Objects == HumanoidRootPart then
		continue
	end
	
	local Invisible_Limb = Instance.new("Part")
	Invisible_Limb.Size = Objects.Size
	Invisible_Limb.Name = Objects.Name .. "_Collide"
	Invisible_Limb.Massless = true
	Invisible_Limb.Transparency = 1
	Invisible_Limb:PivotTo(Objects.CFrame)
	
	local Limb_Weld = Instance.new("Weld")
	Limb_Weld.Part0 = Invisible_Limb
	Limb_Weld.Part1 = Objects
	
	Invisible_Limb.Parent = Objects
	Limb_Weld.Parent = Invisible_Limb
end
1 Like

Thank you so much! But why would Roblox set it up that way? Another thing I found is that you can change the CanCollide property inside the explorer if you’re testing in Studio, and that will work just fine…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.