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

Save models in datastores script, why this not works?

Asked by 6 years ago

Hi!

I'am a noob in scripts, so i wanna ask you whats wrong in this script, what saves model to table and create a key to load it.

First script is this:

function onClicked(click)
local dataStore = game:GetService("DataStoreService"):GetDataStore("ItemSave")
local itemTable = {}

for i,v in pairs(game.Workspace.Tycoon:GetChildren()) do
    table.insert(itemTable, v.Name)
end

local condensedData = game:GetService("HttpService"):JSONEncode(itemTable)
local playerObject = click

dataStore:UpdateAsync(click.UserId, function()
    return condensedData
end)
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

This script is search model in workspace, save it to table (i think) and create a player key to load this model later.

After player rejoin, he was press button what activate this script:

function onClicked(click)
local playerObject = click
game:GetService("DataStoreService"):GetDataStore("ItemSave"):GetAsync(click.UserId)
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

So, this is not work. When i wanna save model, output says: Request was throttled. Try sending fewer requests. Key =(keycensored)

Guys, i hope you really help me, because i create my game so long and i tired, i was created a big count of models and now i write a scripts, so if this script did not work, i need to destroy a lot of my models.

Thanks from future.

0
Thats just a warning. I think its due to studio mostly but you should still be able to make the requests. Also saving the parts name is not the best solution for a save system. Lastly you do not use JSONEncode since Roblox will handle the saving and loading of a table (the format is still saved as a JSON but we do not see it which is good). User#5423 17 — 6y
0
Hmm, interesting. Can you give me an example?? pmainokiborg 6 — 6y
0
You are not using the return value of GetAsync. It does not just magically load back in. hiimgoodpack 2009 — 6y
0
@pmainokiborg I don't like to give out examples with how to save the data since it is your game design. But the two key parts are saving data efficiently so it can also be loaded efficiently and the structure of the saved data ie how easy is it for you to change or add things in without breaking the whole save/load process. User#5423 17 — 6y

Answer this question