How to set a player's CanCollide to true?

I’m making a custom character’s arms ragdoll by replacing the joint with a rope constraint, but they go through the body because their CanCollide is set to false. I’ve tried using collision groups, but they also require CanCollide. How can I set the custom character’s CanCollide to true?

2 Likes

Go into the properties of the arms and turn on cancollide

2 Likes

I tried that, but they automatically get set to false once the character moves.

1 Like

If you are saying you replacing the joint with rope constraint, you can try this in your script:

for i, v in pairs(character:GetDescendants()) do --or whatever your path to character is
     if v:IsA("BasePart") and v.CanCollide == false then
           v.CanCollide = true
     end
end

writing from phone

1 Like

Roblox keeps setting the collision of player parts to false every frame. Setting it to true once won’t cut it. You can loop through the parts in a local script using .RenderStepped to combat this. I do not recommend setting all parts to CanCollide true because it messes with the physics a lot.

3 Likes

i did some quick testing and the character arms keep cancollide on if you change property while game is running so maybe a script would work

1 Like

This worked! I just added while wait(0.1) to the beggining!
Here’s the script. It’s a server script inside of starterCharacterScripts.

while wait(0.1) do
for i, v in pairs(script.Parent:GetDescendants()) do --or whatever your path to character is
	if v:IsA("BasePart") and v.CanCollide == false then
		v.CanCollide = true
end
end
end

2 Likes

while wait(0.1) do is not the best idea i guess, how mikulas12 said you can use game:GetService("RunService").RenderStepped:Connect(function() end)

1 Like

That’s great to hear. Roblox just loves to make our lives harder.

3 Likes

I think that might be too laggy. Wait(0.1) isn’t the most reliable solution, but it works well enough.

1 Like

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