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

My Map Datastore Isn't Saving?

Asked by 2 years ago
Edited 2 years ago

So, I have been making some progress on a new game I'm making, but when I tried making a datastore to save a value that determines whether the player has bought a map, it does not save.

To determine if the player has bought a map, I use BoolValues that save through a Datastore. If the value is false, then the player doesn't have it. If the value is True, the player does have it. But, every time I and my Testers play the game, the datastore never saves and the game makes us purchase the Map again with In-Game currency. This is very frustrating and I am trying to find a way to fix this.

All the BoolValues to save the Maps are located in the ReplicatedStorage

Here is my Datastore Script:

local mds = game:GetService("DataStoreService"):GetDataStore("MapDataStore1")
local rs = game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(plr)
    wait()
    local key = "user_"..plr.UserId

    local mapsave1 = rs.PurchaseSaves.Map2Purchased

    local mapsGetSaved = mds:GetAsync(key)
    if mapsGetSaved then
        mapsave1.Value = mapsGetSaved[1]
    else
        local MapsForSave = {mapsave1.Value}

        mds:GetAsync(key, MapsForSave)
    end
end)

game.Players.PlayerAdded:Connect(function(player)
    local mapsave1 = rs.PurchaseSaves.Map2Purchased

    mds:SetAsync("user_"..player.UserId, {mapsave1.Value})
end)

When I Test and Play the game, it never shows any errors. Any help?

0
Are you using any other libraries for DataStore, or Roblox's default DataStore? GetAsync only accepts one argument and on line 16 you provide two. Also, are there any erorrs in the output (you can reach this in game by pressing F9) TinyPanda273 110 — 2y
0
I am using Roblox's Default DataStore. JackyW9cky 27 — 2y

1 answer

Log in to vote
-1
Answered by 2 years ago

JackYT_gaming123 are you by chance using a tutorial? If so go check the comments and/or the description they may have found a problem in the code or the codes just not giving the player enough time to lode.

0
This is just a suggestion epet6644 0 — 2y
0
Yes, I found out how to make Datastores by using YouTube Tutorials. But, I have been using this method of making a datastore for a very long time, and it always worked. Just this time it didn't. JackyW9cky 27 — 2y
Ad

Answer this question