Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I start this with datastores?

Asked by
yoshi8080 445 Moderation Voter
8 years ago

I was wondering how would I start , like instances in a data store?

I already know that it's not possible unless, you use it in a table which has to be converted into a string.

Any tutorials or places to help me start out?

This isn't a request, it's just something to help me know more on a certain area on a topic

1 answer

Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
8 years ago

Datastore is basically just a service used to store data to a server, which can then be accessed later by a user at any of the places in your game.

Of course, you probably already knew that, so here are a few simple methods you can start off with:


Getting the Datastore

local DataStore = game:GetService("DataStoreService"):GetDataStore(name)

The name parameter is pretty self explanatory. It's just the name that you set for your Datastore, and the way you access it later on.

This is the base method that is always required in fetching the datastore in order for you to use it. This is generally at the start of the script.

Saving Value to a Datastore

DataStore:SetAsync(key, value)

Key is a unique string that the service uses to fetch data for the user or the world. For use with saving individual player data, you would want to use the player's ID as part of the string

Value is simply what you're saving. This can be a number, string, boolean, or a table.

Getting Value from a Datastore

DataStore:GetAsync(key)

Key is the same thing that you used in the SetAsync method. When you use this method, it will return the value previously saved in the datastore with SetAsync.


Now, you'll probably need a bit more explanation than this, and there are some great resources you check out, including the Roblox Wiki

I would also suggest checking out some other resources such as Youtube. Here's one video that may help.


Anyways, I hope this helps. If not, or if you have any further questions, please leave a comment below, and I'll see what I can do to help.

Ad

Answer this question