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

For Loop does not work with Data Stores?

Asked by
Decemus 141
9 years ago

First, I had made a data store for 10 values, and it worked fine and all in my place. I had sent it to someone else and for some reason, it only loaded one value. He had put everything in the right spot. I found it odd, and came here to find the answer to the question. Here is the code, I cut out the variables due to them looking like they did not need to be mentioned.

for i=1,10 do
    wait(.01)
local b = DataStore:GetDataStore("Inv"..i)
    b:UpdateAsync(key, function(oldValue)
        local newValue = oldValue or "None"
        local a = Instance.new("StringValue")
        a.Name = "ToolN"..i
        a.Parent = player
        a.Value = newValue
    end)
end

Yes, I stated player and key.

0
where's the rest of the for-loop? XAXA 1569 — 9y
0
here Decemus 141 — 9y
0
Since it doesn't seem like you're modifying the datastore, why not just use :GetAsync? XAXA 1569 — 9y
0
This would work. BlueTaslem 18071 — 9y
View all comments (2 more)
0
Mind showing the whole script? XAXA 1569 — 9y
0
Alright Decemus 141 — 9y

Answer this question