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

DataStore always saves but, today it didn't? Can't figure out why.

Asked by 6 years ago

The DataStore I made always saves but earlier today, it didn't. I'm super curious to figure out why but I couldn't think of anything. Can someone help me figure out why it would fail like that?

game.Players.PlayerRemoving:connect(function(player)
    local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save")

local statstorage = player:FindFirstChild("Currency"):GetChildren()
for i =  1, #statstorage do
    datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
    print("saved data number "..i)

end
print("Stats successfully saved")   
end)

game.Players.PlayerAdded:connect(function(player)
        local datastore = game:GetService("DataStoreService"):GetDataStore(player.UserId.."Save")

    player:WaitForChild("Currency")
    wait(1)
    local stats = player:FindFirstChild("Currency"):GetChildren()
    for i = 1, #stats do            
    stats[i].Value = datastore:GetAsync(stats[i].Name)
    print("stat numba "..i.." has been found")
        end
end)
0
Did you make an update to it and then it stopped working? Are there any errors or warnings or anything in output? TheBenSquare 47 — 6y
0
I didn't change anything about it. And no, they isn't any errors or warnings. Michael_TheCreator 166 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

To be honest, I'd use google docs as a database, yes it uses web hooks and there's a limit but if you're game is a 24 or less players allowed this is perfect. https://devforum.roblox.com/t/using-google-spreadsheets-as-a-database/12658 -Its more organised, Its also great for receiving loss data.- I know it has nothing to do with your question, I just wanted to spread the word and seen as you was talking about database I thought I'd show.

0
My game is 10 - 12 players, should I still use google spreadsheets? Michael_TheCreator 166 — 6y
0
I would, its more organised and easy to find loss data. xXiNotoriousXx 31 — 6y
0
Thank you, I'll look into it. Michael_TheCreator 166 — 6y
Ad

Answer this question