Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Map Datastore Isn't Saving?

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?

2 comments

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)

0

I am using Roblox's Default DataStore.

1 answer

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.

2 comments

0

This is just a suggestion

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.