How to save user stats

How do I make it so that users can save their game stats, exit, and come back and it still be saved.

code snippet

Do this:

from replit import db,clear
  db['test'] = 1

with this try and except statement, it checks if the player has ‘test’ in the database, if it does not have it in the database, then it creates one for them. But if they do have it, it will print it out and clear the screen.
heres how you can save it:

# a bunch of code here..
test = db['test']
test = 2
def save():
  db['test'] = test
1 Like

You could use localstorage for this, but it can be changed. Try using a backend.


I have made a game that stores the user’s game data and loads it back later. You can see it here:
The game uses ReplitDB.

How would I do that? I’ve been learning a lot from these projects and it’s always nice to learn from someone experienced.

1 Like

wanna take a look at my code and see if you would be able to transfer it to a db?

Sure! Can you send me the code and not the link to your project? It’s easier to navigate and read.
Sorry for the inconvenience.

you can use this to get there I don’t know how to send you a link that goes directly to the code

You can copy and paste the code here but nvm.

Can you send me the link to your project? Thanks so much.

like invite you to it?

No need. Just the link.

I code mainly in Python, so if you want me to integrate ReplitDB into another language it may take me a while.

K i need it in JS. You can fork my program then tell me when your done

Is it possible to send the project’s link and not the website?

I don’t think so. Fork it and you’ll be able to see it all

I can’t fork it from the website.

You may have to get someone’s help and not mine if you are using JS. Maybe @OmegaOrbitals can help.

on the programs on display click the left arrow twice and you’ll see it