CollisionGroups not wokring?

I am trying to make a TD game and used collision groups editor to make it so the enemy can’t touch each other . I was successful at that and tried to use the same script for the player with a few changes, but it won’t work for some reason.

If any other information is needed please tell me.

The character is not guaranteed to be assembled when CharacterAdded fires right now because of some arcane construction ordering. A fix was on the way but some blockers caused it to be pushed back. Not particularly sure when we’re getting that fix anymore.

Your script will work but the parts may not necessarily exist by the time you start looping through the character’s descendants. The way to approach this is to handle any BaseParts that may exist when you loop through but also any new parts (DescendantAdded, is BasePart?, set CollisionGroup).

local function onDescendantAdded(descendant)
    if descendant:IsA("BasePart") then
        -- set group
    end
end

character.DescendantAdded:Connect(onDescendantAdded)
for _, descendant in ipairs(character:GetDescendants()) do
    descendantAdded(descendant)
end
1 Like

The descendants are the enemies that try to get to your base. I will try that thanks!

How would I implement this into my script?