-- NinjoOnline --
local physicsService = game:GetService("PhysicsService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local valuesFolder = replicatedStorage:WaitForChild("ValuesFolder")
local activeValue = valuesFolder:WaitForChild("ActiveValue")
local blueDoor = workspace:WaitForChild("Castle Map").BlueCastle.Hospital.HospitalDoor
local redDoor = workspace:WaitForChild("Castle Map").RedCastle.Hospital.HospitalDoor
local blueForceFields = "BlueForceFields"
local redForceFields = "RedForceFields"
local bluePlayers = "BluePlayers"
local redPlayers = "RedPlayers"
physicsService:CreateCollisionGroup(blueForceFields)
physicsService:CreateCollisionGroup(redForceFields)
physicsService:CreateCollisionGroup(bluePlayers)
physicsService:CreateCollisionGroup(redPlayers)
physicsService:SetPartCollisionGroup(blueDoor, blueForceFields)
physicsService:SetPartCollisionGroup(redDoor, redForceFields)
physicsService:CollisionGroupSetCollidable(blueForceFields, bluePlayers, false)
physicsService:CollisionGroupSetCollidable(redForceFields, redPlayers, false)
local function setCollisionGroupRecursive(object, groupName)
if object:IsA("BasePart") then
physicsService:SetPartCollisionGroup(object, groupName)
end
for _, child in ipairs(object:GetChildren()) do
setCollisionGroupRecursive(child, groupName)
end
end
function onCharacterAdded(character, team)
local collisionGroupName = team.Name .. "Players"
setCollisionGroupRecursive(character, collisionGroupName)
end
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:Connect(function(character)
while wait() do
if tostring(player.Team) ~= "Lobby" then
onCharacterAdded(character, player.Team)
break
end
end
end)
end)
activeValue.Changed:connect(function(value)
if value == false then
-- Remove players from group
end
end)
Right now I have a collision group script which sets players to be able to walk through their own team doors, without being able to walk through the opposing teams doors. I got most of this from the wiki. The problem I am facing however, is 1. It only sets the players collision group when their character respawns and 2. It carries over from round to round. I have a section where if the round is not in progress then I want to clear all collision group, but I want when a new round starts for the new collision groups to be setup according to each players team. Can anyone help me, because I cant't find anywhere how to remove players from a collision group on any of the wikis

1 comment
After a round you could change all of the players team to lobby then just reset the character? There are also events in a team object for when a player is added / removed from that team which you could also use.