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

Can someone figure out the error in my data store script?

Asked by 8 years ago

I have my leaderboard properly made. I need it to save using data stores, but my script isn't working.

datastore = game:GetService("DataStoreService"):GetDataStore("Growth")

game.Players.PlayerAdded:connect(function(player)
    player:WaitForDataReady()
    wait(1)
    local stats = player:FindFirstChild("leaderstats").Growth.Value
    stats = datastore:GetAsync(player.UserId)
end)

for i,v in pairs(game.Players:GetChildren()) do
    for x,c in pairs(v:FindFirstChild("leaderstats")) do
        for a,b in pairs(c:FindFirstChild("Growth")) do
            b.Changed:connect(function()
                datastore:SetAsync(v.UserId, b.Value)
            end)
        end
    end
end
0
Please give us a start to what's wrong. User#5978 25 — 8y
0
I don't know where the error is. lolfacerandomness 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try replacing FindFirstChild with WaitForChild. Also don't do this, because if the value defined is to be changed, the old one is still saved.

value = test.Value
print(value)

use this instead

value = test
print(test.Value)
0
I replaced the FindFirstChild with WaitForChild, but it still hasn't worked yet. lolfacerandomness 0 — 8y
Ad

Answer this question