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)?
Yeah it’s possible, but what do you want the barrier to block, like which player?
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.
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.
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)
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)
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)
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: