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

What is data store, how can i use it and when can i use it?

Asked by
seikkatsu 110
5 years ago

Pretty self explanatory. I would like to get some help on both data stores,for example when can i use, what can i use it for and also what is the difference between datastore 1 and 2? Thanks in advance for all the help.

0
thank you both your answers helped seikkatsu 110 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

Datastore is the ability to save data for when you rejoin, leaving a game and rejoining... where did you read about datastore 1 and 2, theres a single datastore with infinite string storages...

Use it if you want to save a players data, heres an example

local ds = game:GetService("DataStoreService"):GetDataStore("Datastore_1")
local CurrentData = 0 -- this will be overwritten in the future...
game.Players.PlayerAdded:Connect(function(p)
    pcall(function()
        local PersonsData = ds:GetAsync(p.UserId)
        local CurrentNewData = PersonsData[1]
    end)
end)
game.Players.PlayerRemoving:Connect(function(p)
    pcall(function()
        local PersonsData = ds:SetAsync(p.UserId,CurrentData)
    end)
end)
while true do wait(1)
    print(CurrentData)
    CurrentData = CurrentData + 1
end

The Datastore_1 is what I believe you think is datastore_1, a string value where everything is basically stored in...

Use the players user id to save stuff...

API services must be on... Basically just saving a value

To save multiple values use a table not multiple of the "GetDataStore"....

0
thank you! seikkatsu 110 — 5y
0
No problem greatneil80 2647 — 5y
Ad
Log in to vote
2
Answered by
Robb12 12
5 years ago
Edited 5 years ago

Datastores are used for saving any kind of data such as Leaderstats, tools, player location etc.

This may be of some use https://developer.roblox.com/en-us/articles/Data-store

Answer this question