How do i make a model not collide with another model?

So i’m still making a flight simulator. However, i need to make the planes NOT collide with each other. They are models.

Yes, i already made the collision group. And yes, i know what collision groups are. Everything i tried so far didn’t work.

script:

local ps = game.PhysicsService

local planes = "Planes"

for i, v in pairs(script.Parent.Plane.MainParts:GetChildren()) do
	if v.Name ~= "LandingGear" then
		v.CollisionGroup = planes
	end
end

for i, v in pairs(script.Parent.Plane.OtherParts:GetChildren()) do
	v.CollisionGroup = planes
end

ps:CollisionGroupSetCollidable(planes, planes, false)

Help is very appreciated.

3 Likes

Have you tried changing the collision group collision using the Collision Groups Editor?

2 Likes

What do you mean by that? Can you explain?

Make a collision group called “Plane”, or whatever you want really, and uncheck the box that says that “Plane” can collide with “Plane”. I’m on mobile right now, and I don’t exactly remember how to make the checkboxes appear, but I think you had to click on the collision group. Or, if you can’t find how to change that, type “roblox collisiongroup” into google and pick the documentation or one of the tutorials to find how to do it.

I’ll look at that now, thanks.
edit: Im actually so stupid. I have been trying to find out what’s wrong for so long just to realize that the script won’t change my part’s collision groups for some reason. I’ll try to fix that.

So in Studio at the top hot bar next to home select model and the click “Collision Groups”


Then you’ll get this tab where you can create and edit collision groups and yeah.
image
Hope this helps!

Well guys, it turns out that no matter what i do the collision groups don’t change for each part. What do i do now? What’s wrong?

1 Like

You never registered the collission group with PS:RegisterCollisionGroup(“Planes”). Here I wrote a script you can use. Just insert the models in the models table, and the part names that you still want to have collision with plane parts in the badnames table.

I tested it and it works! All the plane parts cannot collide with each other, but the landing gear can.

local PhysicsService = game:GetService("PhysicsService")
local PS = game:GetService("PhysicsService")

local Planes = PS:RegisterCollisionGroup("Planes")
local Models = {
    -- Insert the models here...
    workspace.Model1,
    workspace.Model
}
local BadNames = {
    -- Insert parts of names that shouldn't have the collision group.
    "LandingGear",
}


for _, model : Model in pairs(Models) do
    for _, part in pairs(model:GetDescendants()) do
        if part:IsA("BasePart") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
            if not table.find(BadNames, part.Name) then
                part.CollisionGroup = "Planes"
            end
        end
    end
end

PhysicsService:CollisionGroupSetCollidable("Planes", "Planes", false)

The landing gear is actually supposed to not collide either, sorry for not making that clear

Ah, then just remove it from the bad names table/

Oh also, i use a system that works by the player clicking a part, a gui pops up and the player selects a plane which is then spawned from the server storage, not already in the workspace.

local Models = {
    -- Insert the models here...
    workspace.Model1,
    workspace.Model
}

^ reffering to this piece of code
How do i make that work?

Well, if you spawn the plane, you already have a reference to it. At the top of your spawning script put this code here, this makes a new function for us.

local PS = game:GetService("PhysicsService")
local Planes = PS:RegisterCollisionGroup("Planes")
PS:CollisionGroupSetCollidable("Planes", "Planes", false)

local BadNames = {
    -- Insert names of parts that should still have collission.
    
}

local function SetPlaneCollission(model)
    for _, part in pairs(model:GetDescendants()) do
        if part:IsA("BasePart") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
            if not table.find(BadNames, part.Name) then
                part.CollisionGroup = "Planes"
            end
        end
    end
end

Now in later on in the code when you spawn in the plane, just call the function and pass ini the plane model.

-- Plane spawning system above... assumed you have a "usersPlane" variable referencing it.

SetPlaneCollission(usersPlane)

-- Rest of code...

I pasted the code, but i’m still not sure if it’s working. When i ram into another airplane, it seems to not collide for half a second but then something collides and it goes crazy. What could that be?

I re-checked manually that all of the parts have been set to collision group “Planes”, but something is still wrong

Edit 2: I found out that the gear is actually causing the problem because it’s in a model, but for some reason even when it shows that the collision group is correct it still collides. Huh?