How to use AllowedExternalLinkReferences (GetPolicyInfoForPlayerAsync)

Hi, So I want to achieve on this script, so if a user is allowed Discord it prints “Discord is allowed” I saw this would be possible from the GetPolicy API found here PolicyService | Documentation - Roblox Creator Hub

After playing with it a little bit I found out it prints an array that looks like this:

 {
     [1] = "Discord",
     [2] = "YouTube",
     [3] = "Twitch",
     [4] = "Facebook"
} 

How could I get if Discord is allowed from here tho if I don’t know what prints if your under 13? I tried playing with .Value or = true but none of those work. Could anyone help me :slight_smile:

Are you trying to get a value from a dictionary?

What you can try is first setting the dictionary in a variable and then loop through and find if it exists using

for key, value in pairs(dictionarytable) do
    if value == "Discord" then
       print("User is allowed to use discord")
   end
end
1 Like

Pretty much yeah :slight_smile:
Thanks I will try what you said

Any luck on what I suggested ?

I tried, but I don’t really see a good way to do what you said? :slight_smile:

Do you know how to get the AllowedExternalLinkReferences?

Basically, put that in a variable, we’ll call ReferencesTable


local ReferenesTable = --How you get the dictionary, you change it since I have no experience with it

Then in the loop, jsut do how I did

local ReferenesTable = --How you get the dictionary, you change it since I have no experience with it

for key, value in pairs(ReferenceTable) do
    if value == "Discord" then
       print("User is allowed to use discord")
   end
end

The first thing in the pairs loop is the key, which is not important, we need the value, what’s in each key, if it finds “Discord”, then they can use discord

3 Likes

I kind of do, I managed to get it to print an array but that’s about it
I will try what you sent and add the bit in :slight_smile:

Try doing something like the following code snippet:

table.find(playerPolicy,"Discord") and true or false

Replace playerPolicy with the array. This ternary statement will return true if “Discord” is in the array, false if “Discord” is absent in the array.

2 Likes

Thanks alot! I got it working :smiley:

Glad it worked for you! If you have anymore issues don’t be afraid to make anotehr post!

1 Like