How would i Do CollisionGroupSetCollidable

I tried to go to the https://developer.roblox.com/en-us/api-reference/function/PhysicsService/CollisionGroupSetCollidable but it was moved some where I cant find, now I am stuck with my collisions
part1 and part2

If anyone can educate me that would be nice!

1 Like

If you do not need to dynamically create collision groups I would recommend using the collision groups editor in the Model tab.
image

The link you supplied still works for me!

Ok I have this line of code But how would I change Obstacles to the players Parts?

PhysicsService:SetPartCollisionGroup(game.Players, obstacles)
PhysicsService:SetPartCollisionGroup(workspace.GreenBall, greenObjects)

You would have to go part by part to set the player character’s collision group to anything other than default.

CharacterAdded.Connect(function(character)
    for _, part in ipairs(character:GetDescendants()) do
        if part:IsA("BasePart") then
            -- set part collision group (part, your_group)
        end
    end
end)

This is my current code, Ain’t working

local PhysicsService = game:GetService("PhysicsService")

local obstacles = "Obstacles"
local greenObjects = "GreenObjects"

-- Create two collision groups
PhysicsService:CreateCollisionGroup(obstacles)
PhysicsService:CreateCollisionGroup(greenObjects)
-- Add an object to each group
game.Players.PlayerAdded:Connect(function(plr)
	local characterr = plr.Character or plr.CharacterAdded:Wait()
	characterr:Connect(function(character)
		for _, part in ipairs(character:GetDescendants()) do
			if part:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(part, obstacles)
			end
		end
	end)
end)
PhysicsService:SetPartCollisionGroup(workspace.Ball, greenObjects)
PhysicsService:CollisionGroupSetCollidable(greenObjects, obstacles, false)

I feel like I am doing this wrong

I would suggest using CollisionGroupModule:
CollisionGroupModule.lua (1.1 KB)

	characterr:Connect(function(character)

Delete this line, Models do not have a Connect function, nor do you want to connect to any event.

game.Players.PlayerAdded:Connect(function(plr)
	local characterr = plr.Character or plr.CharacterAdded:Wait()
	for _, part in ipairs(character:GetDescendants()) do
		if part:IsA("BasePart") then
			PhysicsService:SetPartCollisionGroup(part, obstacles)
		end
	end
end)