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

Why doesn't this table saving work? And how to properly save a table?

Asked by 6 years ago

So I have a table in a local script and i pass the table to a server script to save it

local script:

--this is how im passing the table to a server
remoteSaving:FireServer(table)

the table when i tested only had one value inside of it

server script (saving data):

remoteSaving.OnServerEvent:Connect(function(pl, table)
    Items = table
    ds1:SetAsync(pl.UserId, Items)
    print("saved data for"..pl.Name)
end)

then when a player joins i use PlayerAdded event to call a function for getting data, also in the same server script:

game.Players.PlayerAdded:Connect(function(pla)
    Items = ds1:GetAsync(pla.UserId) or {}
    remoteSaving:FireClient(pla, Items)
end)

and when I fire client with that table it crashes because my for loop where i go through the table acts like it has infinite amount of values in it

Anyone knows what im doing wrong?

1 answer

Log in to vote
0
Answered by 6 years ago

il try to fix your script im sorry if this does not help

--Local Script
save = nil
thingys = {"a,b,c"}
thingys:FireServer(thingys)
print(thingys)
Ad

Answer this question