Ad
Log in to vote
1

An Easier Way For Collision Groups?

Asked by 7 days ago
Edited 7 days ago

Hello everyone! Another question from me! :D

Today I was testing Roblox's collision groups feature, and it didn't work. :P I've made many attempts with it, and I just can't get it to work. First, it errored saying it couldn't create a group, now it says it can't create more than 32 groups. I don't quite understand this feature. :P

This's the code I've been using:

local PhysicsService = game:GetService('PhysicsService')
local pl = Workspace:WaitForChild('PLACE') -- A square-ish box with an open door
local fig = Workspace:WaitForChild('TEST_FIGURE') -- A fake player

function Parts(obj)
    local parts = {}
    for i, v in next, obj:GetChildren() do
        if v:IsA('BasePart') then
            table.insert(parts, v)
        end
    end
    return parts
end

local num = 0; local num2 = 0
for i, v in next, pl:GetChildren() do
    print(num, 'PLACE') -- Stops at 12
    for i2, v2 in next, Parts(fig) do
        print(num2, 'FIGURE') -- Stops at 15
        local Walls = 'Place'..tostring(num) -- It got pretty whiny with this
        local Char = 'Char'..tostring(num2)

        PhysicsService:CreateCollisionGroup(Walls) -- Sometimes
        PhysicsService:CreateCollisionGroup(Char) -- Sometimes

        local wall = v; local char = v2
        PhysicsService:SetPartCollisionGroup(wall, Walls) -- Sometimes here
        PhysicsService:SetPartCollisionGroup(char, Char) -- Errors here

        PhysicsService:CollisionGroupSetCollidable(Walls, Char, false)
        num2 = num2 + 1; num = num + 1
    end
end

Is there a simpler way than this? I feel I'm over-complicating it by a bit much. :P Many thanks appreciated. :)

0
10/10 question TheeDeathCaster 1888 — 7d
0
Why do you need a collision group for each individual part? NubgIe 0 — 1h

Answer this question



Ad