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.
What is data store, how can i use it and when can i use it?
2 answers
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"....
2 comments
thank you!
No problem
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
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
thank you both your answers helped