Why's my CollisionGroup not working?

Hey, pretty much the title.
They’re both still colliding into each other, I’m a little unsure what I’m doing wrong.
My goal is to make “Missiles” and “Spaceship” not collide into each other, but they can collide into other things.
Thanks in advanced!
Here’s the code:

local MissilesFolder = game.ReplicatedStorage.MissilesForShop
local ShipFolder = game.ReplicatedStorage.ShipForShop

local Missiles = "Missiles"
local Spaceships = "Spaceships"

local players = game:GetService("Players")
local PS = game:GetService("PhysicsService")
PS:CreateCollisionGroup(Missiles)
PS:CreateCollisionGroup(Spaceships)

PS:CollisionGroupSetCollidable(Missiles, Spaceships, false)

for _, v in pairs(MissilesFolder:GetDescendants()) do
	if v:IsA("BasePart") then
		PS:SetPartCollisionGroup(v, Missiles)
	end
end

for _, v in pairs(ShipFolder:GetDescendants()) do
	if v:IsA("BasePart") then
		PS:SetPartCollisionGroup(v, Missiles)
	end
end
1 Like

Thing is, this will only run once. Assuming more missiles and spaceships get created later on, this code won’t impact them at all. (unless you’re cloning instances from those containers? not too sure)

If so though, just assign the spaceship or the missile to the proper collision group each time they’re made.

1 Like

Right I gotcha. I am actually cloning them later on, but I’ll checkout the assigning them as they’re made and get back to you, thanks

1 Like

Hey, thanks. It ended up working, which is amazing. Thank you very much once again

1 Like