Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to save shop items bought?

Quick and easy question, i have a shop with trails, and pets, how would i save the trails, and pets bought, so no player has to restart on buying everything again?

2 comments

0

Use DataStoreService.

0

^ And OP, refrain from posting requests.

1 answer

To start, you need to learn DataStore, or be lazy and get spoonfed by pre-made code.

There is a good & simple method to save it, here's an a practical explanation:

Before starting,

  • Store all of the tools / items in a folder where a script can access.

When the player leaves

  • Check if they have any tools in their backpack,

    • If they do have tools / items then, (if statement)

      • Store the tools' / items' name that are in their backpack into a datastore. (Table)
    • If they don't have tools / items then, (if statement)

      • Store nil or nothing in the datastore. (nil)

When the player joins back

  • Check if they have any tools / items saved in the datastore,

    • If they do have tools / items in the data store then: (if statement)

      • Look into the folder where all the tools / items are stored, (pairs())

        • Restore the tools / items back into their backpack. (:Clone())
    • If they don't have tools / items in the data store then: (if statement)

      • Don't do anything.

This discussion is preserved as it was. New answers, comments, and votes are closed.