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

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

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.

1 comment

0

thank you both your answers helped

2 answers

✓ Accepted answer

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

0

thank you!

0

No problem

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