How can I connect my discord server and my roblox game using rover?

data["discordUsers"] is what we are looking for. For your problem, we can simply check the length of it since we only need to know if anyone is authorized under that account.

if #data["discordUsers"] > 0 then
  print("authorized")
else
  print("not authorized")
end

To check if the code is working, input USER_ID as 1. It should print “not authorized”.

Attempt to get the length of a NIL value

oopsie doopsie replace response with data

1 Like

Thanks for spending almost half an our helping me, much love.
How can I check if a player has a certain role? theres a property in discordusers under the value 1 named [“roles”] and each role has a id marked under a number value order

1 Like

Those number value orders are discord role IDs. Let me quickly check how to get them

Nono its like a table like this heres an example of how it looks

["dscusers"] = { [1] = ["roles"] = [1] = "roleid"

Yeah, it’s the discord role ID.
In discord settings, enable Developer Mode (in App Settings → Advanced).
Go in your server settings, find the role you will need to check for, and click those 3 dots. There will be a button to copy role ID.

How do I exactly check if that roblox player is roled that id in the discord? do i use for _,v in pairs or

table.find(data["discordUsers"]["roles"], ROLE ID).
Will return nil if the role is not found, returns ROLE ID index if found.
Basically check table.find(data["discordUsers"]["roles"], ROLE ID) ~= nil.

1 Like

It seems to say that data or the table is just nil

The [1] that comes after discorduser is the amount of users in that player, can i ask how to check all of it?

Yeah this doesnt seem to work i need a method to find the numerical value of the roles and the player profiles otherwise its looking for nothing

Is your ROLE ID a string or a number? You need for it to be a string.

Its a string, the errors in your solution is that the roles is marked by numerical value so is the player profiles

I guess you can do data[“discordUsers”][1][“roles”] in that case.

I did that its now the roles part, it marks all the roles you have by numerical value. is there a way to do that or use maybe for i,v

I don’t really understand, do you mean you want to loop through the roles? Because this

should work just fine.

SInce the roles are listed by numerical value so lets say the players role is 1 and the role needed is 2

And you add a role and the role needed goes to 3.

I want to loop through the roles to check which one has the role wanted

Oh you mean the role index.
table.find returns the index of the first occurance of needle. That means you can just re-use this

table.find(data[“discordUsers”][1][“roles”], ROLE ID)
1 Like

Kay then it doesnt work because it doesnt find the role.
I put the role id as a developer role which is my role.
I added a attribute which goes to true if i have that role and it just stays on false with no error

Actually nevermind, wrong guild. sorry

1 Like