In a game I am making, I have hazards that players have to work together to cross based on what team they are on. I use the team system to allow immunity to certain teams from specific hazards so that players work together to tackle obstacles. I wanted one team to be able to walk over gaps to access things that other players can't by using a local block that would only have CanCollide set as true for that one team, I used a local script inside of the StarterPack that would do all of this, however, it will only work if players spawn as the team that walks over the gap, and I have points where players can switch teams to add more depth to puzzles meaning that the players who should be able to pass gaps would instead fall. I had tried using "repeat" to make the script continuously loop allowing players to change teams in the same life and still gain the effects of the new team instead of having to respawn as the new team and loose progress, but it did not seem to work, after fiddling with the script, searching free models for something that might help and looking up tutorials, I had finally come here for help, any help on this would be greatly appreciated, here is the script
local part = Instance.new("Part", workspace) --Part is inside of workspace
part.BrickColor = BrickColor.new(25) --Change all the "..."s to any value you want!
part.Size = Vector3.new(526, 0.2, 605.58)
part.CFrame = CFrame.new(1867.82, 27.621, -95.245) --The position
part.Name = "Fly"
part.Anchored = true
part.Transparency = .5
local player = game:GetService("Players").LocalPlayer --The player
if player.TeamColor == BrickColor.new("Bright red") then --If they're a bright red color OR if they're BrickColor.Green (Bright green) then... (you can add more "or"s)
part.CanCollide = true --Let them walk through
else --If they're any other color then... You can do "elseif" to add another if then statement.
part.CanCollide = false --Block the enemy players!
end
