Problem with Reading Tables Contents

Hello DevFourm, I am trying to make a whitelisting system where a player’s userid is inside a table they can use the “DevPanel” I have implemented into my game.

Problem: However I am having a problem reading all of the items in the table. Before adding others, I used this same script with only my userid in the table, the script worked just fine. But when I started to add others to the table the script stopped working and only one of the 3 of us got the “DevPanel”.

Script: Here is my script I am using for the whitelist (Local Script)

-- Veriables
local button = script.Parent

-- Allowed Players
local allowed_players = { -- List of allowed players UserIDS
	181516352,
	1950786284,
	3499223725
}

for i, v in ipairs(allowed_players) do -- Check if the local players userid matches any of the ones in the table above
	if game.Players.LocalPlayer.UserId == v then
		button.Visible = true
		
	else
		
		script.Parent.Parent:Destroy()
	end
end

Any help would be amazing! Thank you :slight_smile:

1 Like

I would expect that if your usedid does not equal the first in the list, then it will immediately destroy the button due to how your check works.
Instead, loop thru the userid table, it a match is found, set a isAdmin bool to true. At the end of teh script & outside of the isAdmin checks, destroy the button if isAdmin is false.

tbh I prefer doing the checks on the server as the players joins, then clone the Admin UI from server storage as it is safer.

Okay, thank you! I’ll try that out! Edit: Thank for your help :slight_smile:

1 Like

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