How can I save data in a webserver?

Hi! I’m developing a place analyzer program called Yarbo. This program will be able to get basic statistics (visitors, servers, etc…). But if the user adds the YarboLoader which I’m developing. Everytime someone joins the game the Module need to send the player name and profile Id to a webserver. I already have the webserver I just need to know how to send data from the game to the webserver (and then storing it). I would appreciate if you can write the webserver code in JS so it’s more easier for me to understand.

The goal that I want to achieve: Begin able to send data from the roblox game directly to a webserver and then storing it. Begin able to get the data from the webserver and displaying it.

Thanks for the help!

1 Like

Add some kind of database to your server.

There are many options, choose the simplest! There are probably many tutorials for doing this with NodeJS (which I’m assuming is what you’re using?).

Make a post request from the module to your server using HttpService | Roblox Creator Documentation with the data you wish to save encoded as JSON.

Then on the web server side, save that data into the database.

Loading data is the reverse. Make a GET request from the game, load the correct key from the database, send it back.

See how far you can get and then come back with more specific questions ;). This forum is not the best for asking about JavaScript though. There are lots of tutorials online.

1 Like

First of all thanks for the answer. Yes I’m using NodeJS but could you be more specific on how would I save the data? Like what url should I put in the HttpService:PostAsync() function? And another question.

What do you mean by key?

Well, you’d need to host your web server somehow, and then the URL is just the URL of your web server.

If you’re just running your game in studio and testing, you could listen on port 3000 or something (google “how to handle POST request with express” or something) and then do

HttpService:PostAsync("http://localhost:3000/save_game_data", myJsonData)

That will only work from studio though. You need to expose your server to the internet somehow, which means you either pay someone else (like AWS or heroku) to host it for you, or you host it yourself and expose your machine to the internet by forwarding a port.

Then the “localhost” in the URL becomes the public IP of your computer.

The key in whatever database you go with. This is like a key in a DataStore on Roblox.

You gotta pick a database first and figure out how to create one, then how to connect to one through NodeJS.

MongoDB seems popular, but I’m not an expert on it. Google around for some tutorials on MongoDB.

This one seems fine for creating the database locally, and this one tells you how to connect to it from node.

There’s also a bunch of stuff and tutorials about “mongo atlas” or something out there, which is some cloud hosted database I guess. Maybe you want to use it for yours, up to you.

1 Like

I’m using Firebase as Database (From Google)

Okay, then use that. Never have myself.

https://indepth.dev/posts/1084/building-an-api-with-firebase seems like a relevant tutorial for you.

u can use replit to store the data. just create a webserver in python and repl.it gives a domain, so u use it and send the data to their servers

you mean the pre-set code in replit lol