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

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

Asked by 4 years ago

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

0
scriptinghelpers is not a request site. Dovydas1118 1495 — 4y
0
ScriptingHelpers is NOT a request site. It is a site to help people with scripting issues. Please read the TOS and Rules. killerbrenden 1537 — 4y

Closed as Not Constructive by Nguyenlegiahung, JesseSong, killerbrenden, jediplocoon, matiss112233, and TaxesArentAwesome

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

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

Ad