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

How to make a data store with tables?

Asked by 7 years ago
Edited 7 years ago

I need a data store that has three tables in it. I have this so far. I don't know how to make it so that it saved tables.

local DATA = game:GetService("DataStoreService"):GetDataStore("SaveNames");

game.Players.PlayerAdded:connect(function(player)
    local blocks = Instance.new("Folder", player)
    local names = Instance.new("StringValue", blocks)
    local positions = Instance.new("IntValue", blocks)
    local sizes = Instance.new("IntValue", blocks)
    blocks.Name = "Blocks"
    names.Name = "Names"
    positions.Name = "Positions"
    sizes.Name = "Sizes"
    if DATA:GetAsync(player.userId) then
        names.Value = DATA:GetAsync(player.userId)[1]
        positions.Value = DATA:GetAsync(player.userId)[2]
        sizes.Value = DATA:GetAsync(player.userId)[3]
    end
end)

game.Players.PlayerRemoving:connect(function(player)if player:FindFirstChild("Blocks") then
        DATA:GetAsync(player.userId, {player.Blocks.Names.Value, player.Blocks.Positions.Value, player.Blocks.Sizes.Value})
    end
end)
0
This aint a request site greatneil80 2647 — 7y
0
Its a help site and I need help.. goldstorm950 65 — 7y
0
The point of SH is not to provide free scripts - which whatever way you put it, is exactly what you are asking for - but to provide help with existing code or a question with 'special permission' to be codeless. TheDeadlyPanther 2460 — 7y
0
You should try making a DataStore yourself, then show us the code you are having trouble with if you encounter a problem. TheDeadlyPanther 2460 — 7y
View all comments (3 more)
0
Ok ill post the datastore I have rn goldstorm950 65 — 7y
0
You can use :JSONEncode to turn a table into a string, then :JSONDecode to turn it back into a table. hiimgoodpack 2009 — 7y
0
So put it into a string to save it and then put it into a table to use it? goldstorm950 65 — 7y

Answer this question