Gate would not let certain teams out

Hey.

I’m making a city game, and there’d be a gate where only certain teams can pass, and the teams that cannot pass cannot go through. I made a localscript that does it, but it only works for 1 team, if I put multiple, it would make it pass for all teams, which I don’t want.

local player = game.Players.LocalPlayer
local teams = game:GetService("Teams")
local door = game.Workspace.Gate

while true do
	if player.Team == teams.Civilian or teams.Leader or teams.Admission then
		door.CanCollide = false
	else
		door.CanCollide = true
	end
	wait(0.1)
end

The localscript is in PlayerScripts, because it only worked there for some reason.

2 Likes

I’m not sure how to explain this, but I think you have to add this:

if player.Team == teams.Civilian or player.Team == teams.Leader or player.Team == teams.Admission then

Basically, after every “or/and” you have to make a new statement. For example: player.Team == teams.Civilian is a statement, and player.Team == teams.Leader is a statement. I might be wrong, but at least you can try it. (Sorry, I don’t know how to explain it very well. I just know how it works)

2 Likes

You explained it fine, and it worked. Thanks :slight_smile:

2 Likes