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

How to Save Because i have a problem on yt tutorials?

I have a problem i want to know DataStoreService but i cant take it from yt tutorials. Can someone write in the comments about whole DataStore very easily and aslo really saying about that things that are in the script. Pls

2 comments

0

scriptinghelpers is not a request site.

0

ScriptingHelpers is NOT a request site. It is a site to help people with scripting issues. Please read the TOS and Rules.

1 answer

✓ Accepted answer

When creating a datastore you use the Datastore service within ROBLOX.

You would first have to create a value within the player upon joining the game, in this case I will use money as an example. To do that you would have a starter player script with something like the following:

local money = Instance.new("IntValue",player)
money.Name = money

This would create the value within the player.

Next, you'd have to use the :GetAsync to get the player's value from the datastore. Remember to get the Datastore service. Something like as follows:

local playerStorage = game:GetService("DataStoreService"):GetDataStore(tostring(player.userId))

playerStorage:GetAsync("money")

During the game if the datastore is to change you should update it using :SetAsync. Keeping in mind playerStorage has already been defined. Something like as follows:

playerStorage:SetAsync("money",500)

Setting the money value to 500

Play around with it a little and read this article for more information and help: https://developer.roblox.com/en-us/articles/Data-store

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