Allowing users in who are in the table

Hi, I am trying to make it so that if the game is in debug mode, the usernames that are in the table can join. It seems to be kicking everyone. Here is my code:

local debug = true
	
	local DebugAdmittedUsers = {"WooleyWool", "MysticalLuma"}
	
	if debug == true then
		for i = 1, #DebugAdmittedUsers, 1 do
			if player.Name == DebugAdmittedUsers[i] then
				--User is allowed
			else
				player:Kick("The game is currently in Debug mode. Only those who are a part of the Debug team can join. Please come back later.")
			end
		end
	end
local DebugAdmittedUsers = {"WooleyWool", "MysticalLuma"}

function isInTable(tableValue, toFind)
	local found = false
	for _,v in pairs(tableValue) do
		if v == toFind then
			found = true
            break
		end
	end
	return found
end

if debug then
	if isInTable(DebugAdmittedUsers, player.Name) then
		-- allowed
	else
		player:Kick()
	end
end

I’m sure something like that should work.

2 Likes

Another solution would be to just use the names as indexes so you can do this:

local allowed = {
  ['WooleyWool'] = true;
  ['MysticalLuma'] = true;
}

if debug then
  if not allowed[player.Name] then --Check if they aren't in the table, or you can set a name to false so they're specifically black listed.
    player:Kick()
  end
end
1 Like

Couldn’t I just put return instead of that – allowed?

He was just saying that you can do what you want there if they’re allowed.

1 Like

I know, there’s nothing lol. I just need those users not to be kicked. That’s why I am wondering if return does anything.

Just do

if not isInTable(DebugAdmittedUsers, player.Name) then
	player:Kick()
end
1 Like