Door code isn't working as wanted

Basically, I have this door code, and the door is meant to be able to be opened by 2 teams; KBG and Board of Directors. For some reason, any team can still open the door. Any clue why? Keep in mind, this is a ServerScript inside of a model of a button.

local TS = game:GetService("TweenService")
local groupID = 32029896
local DoorPos = game.Workspace.Door.DP

local TI = TweenInfo.new(
	1,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	false
)

local properties = {Position = Vector3.new(2, 11.25, -12.875)}
local p2 = {Position = Vector3.new(2, 4.25, -12.875)}

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if player.Team == "KGB" or "Board of Directors" then
		TS:Create(game.Workspace.Door.Main, TI, properties):Play()
		wait(4)
		TS:Create(game.Workspace.Door.Main, TI, p2):Play()
	end
end)

Any help is appreciated.

if player.Team == "KGB" or "Board of Directors" then
This line is the problem, this statement reads as:
“If player’s team is “KGB” or “Board of Directors” is not falsy then”

the "Board of Directors" is not falsy then is important, since that basically means not nil and not false and a string is neither nil nor false so then the statement passes.

Additionally, a Roblox Team is not a string, but it has a property called Name which is probably the string you’re looking for. So you’ll want to look at player.Team.Name instead of player.Team.

The statement that I believe you want is:

if player.Team.Name == "KGB" or player.Team.Name == "Board of Directors" then

Thank you very much! I am not amazing with team coding, so I appreciate the help!

Have a wonderful day!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.