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

What to do with my old game if the Roblox's Table-saving DataStore is deprecated?

Asked by 7 years ago

So I have an old survival game back in 2017, I've created a DataStore script that saves tables:

You may have the full script here:

01local Storage = game:GetService('ReplicatedStorage')
02local ItemsFolder = Storage:WaitForChild('ItemsFolder')
03local DataStoreService = game:GetService("DataStoreService")
04local InventoryData = DataStoreService:GetDataStore("PlayerInventory")
05local ItemsList = {}
06for i,item in pairs(ItemsFolder:GetChildren()) do
07    table.insert(ItemsList,item.Name)
08end
09 
10game.Players.PlayerAdded:connect(function(plr)
11    local scope = "Player_"..plr.UserId
12    local InvFolder = Instance.new('Folder')
13    InvFolder.Name = "InventoryFolder"
14    local PlrItemObj = {}
15 
View all 39 lines...

At the line "PlrItemObj[i].Value = DataFile[i]"

I get this error "attempt to index local 'DataFile' (a number value)"

So is there another way to fix the DataStore?

P/s: If you're suggesting to save the data values one by one then you can't since the game have more than 100 items then it would throttle the firing due to limited DataStoreService requests.

1
This code would never have worked with a data store. You save a value in a table which is saved ie {24, 5, 3}. You then index this and try to acces .Name which is incorrect since this data was bit saved. This is for the print statment only. User#5423 17 — 7y
1
Nothing about datastore tables is deprecated. You've obviously SetAsync a number value in a different script. obv we're not gonna fix that cabbler 1942 — 7y
1
The error is saying that DataFile is a number, but you are treating it as a table. Check where you are saving scope to make sure you are saving it as a table. justoboy13 153 — 7y
0
What does your table look like? Dog2puppy 168 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

I would recommend turning it into JSON format right before saving it via datastore. Once the data is called you can convert it back to its table form.

A really good article on how to do this is through the following: https://www.robloxdev.com/api-reference/function/HttpService/JSONEncode

If you have any questions or issues, please contact me. ;)

Ad

Answer this question