How can i do this and is it possible?

So i want to create a barrier which only blocks players from passing, is this possible and how would i do it without causing to much trouble (eg keeps teleporting them back or killing them)?

1 Like

Yeah it’s possible, but what do you want the barrier to block, like which player?

1 Like

I want a barrier to block all players on a certain team eg red team can pass the barrier but blue team cant.

Yeah, then it can be easily done.

1 Like

Whenever the barrier gets touched by a player, you can check if that player is in the desired team and if the player is in the team that is allowed to go through the barrier then set the CanCollide property of the barrier to true and vice versa.

1 Like
local RedBarrier = -- Put your barrier here

RedBarrier.Touched:Connect(function(hit)
    if game.Players[hit.Parent.Name].Team == game.Teams.Blue then
        RedBarrier.CanCollide = false
    end
end)
2 Likes

Wouldn’t that cause the barrier to be no collide for all thought so an opposing team member can just walk though also

local barrier = game.Workspace. -- Your Barrier Here

barrier.Touched:Connect(function(hit)
    local player = hit.Parent.Name
    if hit.Parent:FindFirstChild("Humanoid") and player.Team == game.Teams.Red then
        barrier.CanCollide = false
end)
1 Like

oh sorry
just put this:

local RedBarrier = -- Put your barrier here

RedBarrier.Touched:Connect(function(hit)
    if game.Players[hit.Parent.Name].Team == game.Teams.Blue then
        RedBarrier.CanCollide = true
    else
        RedBarrier.CanCollide = false
    end
end)
1 Like

You could also try messing around with collission groups if you just want the Team to correspond to each Barrier in their own respective order, here’s a video example:

Collision-Groups

4 Likes