I am trying to create a script that when a player clicks a button on a gui, it gets the players user id and compares it to a table of whitelisted user ids. If the id is on the list, the button will work, and if not, the player will receive an access denied message.
My problem is that when the script cross checks the user id with the table, it always returns nil even when the id is in the table. Am I doing something wrong? I’ve done server whitelists in similar ways and it’s worked. The pertinent parts of the script are copy pasted below.
I’v had the script print out the user id of the player as well as the id from the table and they match, but when cross comparing it says that they don’t match. Also, I don’t know if this affects anything but the script is a local script.
--removed unimportant variables
local player = game:GetService("Players").LocalPlayer
local authorized = {
"134011045",
"226959290",
"1360202347",
}
--unimportant functions removed
button.Activated:Connect(function()
if not table.find(authorized, player.UserId) then
button.Visible = false
button.Selectable = false
error1.Visible = true
wait(2)
button.Visible = true
button.Selectable = true
error1.Visible = false
else
if started == false then
start()
else if terminated == false then
terminate()
end
end
end
end)