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

Why does the following code output nothing and not save the data?

Asked by 3 years ago
game.Players.PlayerRemoving:Connect(function(player)
player.CharacterRemoving:Connect(function(character)
    for i, v in pairs(character:GetChildren()) do
        if v:IsA("BoolValue") then
            if game.ReplicatedStorage:FindFirstChild(v.Name) then

                local UserId = "Player_"..player.UserId..v.Name

                local data = {
                    Money = player.Money.Value;
                    Kunai = player.Kunai.Value;
                }
                    local success, errormessage = pcall(function()
                        GameData:SetAsync(UserId, data)
                end)
                if success then
                    print("Data Saved Succesfully")
                else
                    print("Data Did Not Save Correctly")
                    warn(errormessage)
                end

            end

        end
        end
    end)
end)
0
what if you delete "warn(errormessage)" ? NGC4637 602 — 3y
0
or delete end at line 25 cuz i don't see anything wrong with the datastore part of this script. and i don't think you can warn a pcall :v NGC4637 602 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Try making data into a dictionary rather than an array. I don't think you can save arrays.

Ad
Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago

Is this already answered? You can't save tables. Look at my answer here: https://scriptinghelpers.org/questions/123765/why-isnt-this-data-store-saving-the-pcall-says-it-is-working

Answer this question