Collision groups working perfect on R6 characters, but wonky on R15 characters

This code:


local function CharAdded(x)
	for _,v in ipairs(x:GetDescendants()) do		
		if v:IsA('BasePart') then
				v.CollisionGroup = 'players'
		end
	end
end

Works flawless with R6 characters but with R15 characters, when the smaller npc touches you after it moves, itll lift you. I believe this is something to do with CanCollide, so i set the cancollide to true so that collision groups could register, however this ends in the movement completely wonky.

1 Like

For whatever reason characters and the order in which they are loaded aren’t guaranteed to be atomic such that the descendants may load after the CharacterAdded event fires, so my guess is that this is the behaviour you’re experiencing.

You would probably have to listen for a descendant to be added in addition to your loop, just in case this loop runs before all of the char’s limbs have been loaded. Note you should probably disconnect the DescendantAdded connection when a new character is added.