How do I have to change this script so that two teams can get through the door? I would like to make a door through which only the two teams "Staff" and "Developer" can pass. All other players who are assigned to the "Visitor" team should not be able to pass through. The script is from the Developer Hub. However, I can't really make out of it ^^.
Would it also be possible, since the script is in the "ServerScriptService" and several doors are to be controlled simultaneously with this script, to somehow select all of them from a folder?
Thank you for your great help. Without you one would be really lost ^^
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
PhysicsService:CollisionGroupSetCollidable(blueDoors, bluePlayers, false)
PhysicsService:CollisionGroupSetCollidable(redDoors, redPlayers, false)
