Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Collision Filtering does not want to work?

I wanted to learn about this service so I followed the developer hub and came up with the code that I here. The only problem is that is doesn't want to work at all. I have no idea what goes wrong because I get no errors. Help is very appreciated.????

local PhysicsService = game:GetService("PhysicsService")

-- Define parts
local part = game.Workspace.Part
local notCollide = game.Workspace.NotCollide
local collide = game.Workspace.Collide

-- Create group names
local obstacles = "Obstacles"
local greenObjects = "GreenObjects"
local partGroup = "Part"

-- Create the collision groups
PhysicsService:CreateCollisionGroup(obstacles)
PhysicsService:CreateCollisionGroup(greenObjects)
PhysicsService:CreateCollisionGroup(partGroup)

-- Add the object to the groups
PhysicsService:SetPartCollisionGroup(notCollide, obstacles)
PhysicsService:SetPartCollisionGroup(collide, greenObjects)

PhysicsService:CollisionGroupSetCollidable(obstacles, partGroup, false) -- Sets the collision of the part and the obstacle
--to be false
PhysicsService:CollisionGroupSetCollidable(greenObjects, partGroup, true) -- Sets the collision of the part and the obstacle
--to be true

1 answer

Figured it out. I forgot to set a group to my part that I need to actually not collide with the other part. Where I set the objects to their collision group, all I needed was this:

PhysicsService:SetPartCollisionGroup(notCollide, obstacles)
PhysicsService:SetPartCollisionGroup(collide, greenObjects)
PhysicsService:SetPartCollisionGroup(part, partGroup)

This discussion is preserved as it was. New answers, comments, and votes are closed.