Pastebin whitelist problem need help

so i made a admin gui with a whitelist thingy and its not working???

code:

local whitelistedkeys = "lolololl"

function whitelist()
    if whitelistedkeys[TextBox.Text] then
        djaijdaidnaiwdnaidnwhdniwh8237283728n8eh2n8e2e2n = true
    else
        djaijdaidnaiwdnaidnwhdniwh8237283728n8eh2n8e2e2n = false
    end
end

TextButton.MouseButton1Click:connect(function()
whitelist()
if djaijdaidnaiwdnaidnwhdniwh8237283728n8eh2n8e2e2n == true then
    print ("whitelisted")
elseif djaijdaidnaiwdnaidnwhdniwh8237283728n8eh2n8e2e2n == false then
    print("no")
end
end)

what it does:
enter right key

checks, if right prints whitelisted else prints “no”
but when i input the correct key it still prints no?

this is the thing inside the pastebin
“key1”, “key2”

yes i need epic help

Why the ridiculously long variable names?? :tired_face:

This script works fine, but you’re checking if the Textbox.Text is a key inside the string “lolololl”?? Did you mean to make whitelistedkeys an actual table? E.g

local whitelistedkeys = {["Key1"] = true, ["Key2"] = true}
1 Like

like a
keys = “key1”, “key2”

if Key.Text == keys then

end

but i put the keys in the pastebin so i can update it real time
but when i enter the right key it prints no

Variables cannot contain more than one value, so “key2” is discarded in favor of “key1”. Strings have a metatable that has an __index field which points to the string table. Use a key that’s not in the string table and you get nil as a result.

So this ends up being Key.Text == "key1"

Use @mario118118’s suggestion.

local whitelist = {
    key1 = true,
    key2 = true
}

if whitelist[Key.Text] then
    -- something
end
1 Like

i do this

local whitelistedkeys = "https://pastebin.com/raw/bxW1eFRb"

to get the pastebin right?

Well to actually get the keys from the website you use HttpService functions. And only the server can make web requests so if the client really needs the keys from a website, use RemoteFunctions to get a table of the keys.

how do i get the keys???

you should use JSONEncode to encode a table of keys (on pastebin), then use JSONDecode to get the keys (on studio)

to encode: local keys = {key = true} warn(game:GetService('HttpService'):JSONEncode(keys)) --// copy the output to pastebin

to decode: local ret = game:GetService('HttpService'):JSONDecode(game:GetService('HttpService'):GetAsync('https://pastebin.com/raw/bxW1eFRb')) --// do whatever you need to do

1 Like