Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I categorize a ROBLOX group into a CollisionGroup?

Asked by 4 years ago
Edited 4 years ago

Between lines 35-37 is where the categorization from the character concurs. I just need help categorizing this process into ROBLOX groups nor teams. I would greatly appreciate if you were to help.

Reference to project : (https://developer.roblox.com/en-us/articles/Collision-Filtering-Team-Doors)

local PhysicsService = game:GetService("PhysicsService")

local blueDoors = "BlueDoors"
local redDoors = "RedDoors"

-- Create door collision groups
PhysicsService:CreateCollisionGroup(blueDoors)
PhysicsService:CreateCollisionGroup(redDoors)

-- Add doors to their proper collision group
PhysicsService:SetPartCollisionGroup(workspace.BlueDoor, blueDoors)
PhysicsService:SetPartCollisionGroup(workspace.RedDoor, redDoors) 

local bluePlayers = "BluePlayers"
local redPlayers = "RedPlayers"
-- Create player collision groups
PhysicsService:CreateCollisionGroup(bluePlayers)
PhysicsService:CreateCollisionGroup(redPlayers)

local function setCollisionGroup(character, groupName)
    for _, child in ipairs(character:GetChildren()) do
        if child:IsA("BasePart") then
            PhysicsService:SetPartCollisionGroup(child, groupName)
        end
    end
    character.DescendantAdded:Connect(function(descendant)
        if descendant:IsA("BasePart") then
            PhysicsService:SetPartCollisionGroup(descendant, groupName)
        end
    end)
end

local Players = game:GetService("Players")

local function onPlayerAdded(player) --HELP1
    local function onCharacterAdded(character) --HELP2
        setCollisionGroup(character, bluePlayers) --HELP3
    end
    player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

PhysicsService:CollisionGroupSetCollidable(blueDoors, bluePlayers, false)
PhysicsService:CollisionGroupSetCollidable(redDoors, redPlayers, false)

Thank you.

1 answer

Log in to vote
0
Answered by 4 years ago

Not sure but MAYBE this: You can't use some part of what ur doing. When you did player.CharacterAdded:Connect(onCharacterAdded), replace it with this (line 39)

onCharacterAdded(player.Character)
Ad

Answer this question