Is there any way to connect some discord server information and connect it into my roblox game?

Hello! So, on my game, we got a discord server with an economy system, witch is managed by my discord bot. I was wondering if there’s any way to connect for example a player’s balance from discord and being displayed on the player’s UI. Of course, every single user is verified via bloxlink, so roblox account is connected, anyways, i’m new on that, so if someone could help me out with this, that would be amazing!

2 Likes

Create an HTTP server that would provide player data, request it from roblox.

1 Like

Hey! So i’m pretty new on these stuff, if you could explain how to do that, it would be really helpful for me.

1 Like

Yes, it is possible to connect information from a Discord server to your Roblox game. One way to do this is by using Discord webhooks. A Discord webhook is a useful feature that allows developers to send messages without using a bot (and in turn a web server). These webhooks can be used through POST requests and can only be used to send messages.

To set up a webhook on your Discord server, you can follow these steps:

Open the Discord server where you want to place webhook

Click the drop-down arrow and open Server Settings.

Open the Webhooks tab and click Create Webhook

Configure the webhook according to your preferences and save the link (we will need this later).
After setting up the webhook, you can interact with it in Roblox using the HTTPService service. Make sure the HTTPService is enabled before trying to use it. You can use HTTPService’s PostAsync function to send POST protections to the webhook and send messages to your Discord server from your Roblox game.

Here’s a basic example of how you can use a Discord webhook in Roblox:

local http = game:GetService("HttpService")
local Data = {
  ["content"] = "Hey! this is an message from Roblox!"
}
Data = http:JSONEncode(Data)
http:PostAsync("<URL>", Data) -- Place the link you saved between two quotation marks.

you can also see this tutorial: Discord Integration: A guide on using Discord through Roblox [UPDATED]

1 Like

Yes. You’ll need a webserver where Roblox is able to see your data through HTTP requests.

The first thing you need to set up is an http-accessible database which contains the values you want to be shown on Roblox. I don’t know your setup or anything so I can’t tell you how to do this.

One way to do this would be to set up a server and when a transaction (an update to the data) is made on Discord, your computer automatically copies that data to store in a JSON file on your webserver.

Example public database which stores user data:

{
  "users": [
    {
      "username": "username999",
      "balance": 1000
    },
    {
      "username": "cool47",
      "balance": 500
    },
    {
      "username": "hi123",
      "balance": 750
    },
    {
      "username": "bye321",
      "balance": 2000
    }
  ]
}

Let’s say your webserver is located at http://192.168.1.254. On Roblox, all you have to do is make a request to the file and parse the data for what you’re looking for.

Example script:

local url = "http://192.168.1.254/users.json" 

local jsonStr = game:GetService("HttpService"):GetAsync(url)

local data = game:GetService("HttpService"):JSONDecode(jsonStr)

if data and data.users then
    for _, user in pairs(data.users) do
        local username = user.username
        local balance = user.balance
        -- Do whatever you want with the parsed values:
        print("Username: " .. username .. ", Balance: " .. balance)
    end
else
    warn("error")
end

You don’t have to use your own computer for the server, but if you’re running a Discord bot I assume you already are. You could use a cloud service like Google or AWS, or even use Github if you want to do it for free.

Let me know if you need anything else.

I see, my Idea is to make a script via replit for code my economy bot, then using some database website for save all the data, I would like to connect that information (in this case, the balance of every user), and display that balance on my UI.

1 Like

I see but that script would only be useful for send messages into discord via roblox scirpts, but I want to make it inverse, use discord & replit bot scripts with a database and use the database balance from an username and connect it into my game.

1 Like

If you don’t have your own server then I’d recommend using Github to store the data. Keep in mind Github limits authenticated requests to 5000/hour so if your bot is going to write to the database more than that, you’ll actually have to pay for hosting.

1 Like

Here’s an example Discord bot that does something similar that I wrote for someone else. Instead of storing balances, it stores messages — it’s just an example of how to trigger & use the Github API. You’ll obviously have to write your own system. If you need help with the code I can explain it to you.

Then, on Roblox, you’d have periodically query (with HttpService) the raw.githubusercontent.com/USERNAME/REPO/BRANCH/path/to/file.json endpoint and update the UI inside the game with the new parsed values.

2 Likes