Setting a part's collision group

Following an angry warning from my console yelling at me:

SetPartCollisionGroup is deprecated, please use BasePart.CollisionGroup instead. More info: https://devforum.roblox.com/t/updates-to-collision-groups/1990215

I’ve replaced all instances with BasePart.CollisionGroup = "".

The warning disappeared, meaning I’ve covered all instances.

When trying to set the collision group of a player’s character I’ve used the following code:

local function SetCharacterCollisionGroup(character)
	for i, v in ipairs(character:GetChildren()) do
		if v.ClassName == "CharacterMesh" or v.ClassName == "ShirtGraphic" then
			v:Destroy()
		elseif v:IsA("BasePart") then
			print("SET", v.Name)
			v.CollisionGroup = "Player"
		end
	end
end

The word “Set” prints 7 times in the console, with the correct BasePart following after it. However, when viewing its properties during runtime, the CollisionGroup is still “Default”.

I’ve tried turning setting .Archivable to true to no avail.

Why doesn’t the script work? It’s in a serverscript, and when pasting into the console, it WORKS.

1 Like

Can you press Ctrl+Shift+F, then do a global search for SetPartCollisionGroup? It should show you any instances of SetPartCollisionGroup that you haven’t removed

this should work

game:GetService("PhysicsService"):RegisterCollisionGroup("Player")

BasePart.CollisionGroup = "Player"

you can also do this

game:GetService("PhysicsService"):CollisionGroupSetCollidable("group1", "group2", false)

They’re all gone. I’ve ctrl+f’d every script

also:

The warning disappeared, meaning I’ve covered all instances.

Ctrl+Shift+F search it instead, you may have missed a script

The warning disappeared, meaning I’ve covered all instances.

What’s the issue then?

Setting the CollisionGroup doesn’t… work?

did you try this?

character

Yes I did, it was declared at the top of the script, which I didn’t show.

General update on the problem:

I added a task.wait(1) before changing the collision groups and that appears to have solved the problem. I don’t really trust this 100% though…