Datastore not working no matter what

I am trying to set up a datastore system to save a large amount of boolean values based on what the player has unlocked. Just now, the script refuses to save any amount of data. It appears to load perfectly fine, but absolutely nothing is properly saving.

The script has been working fine for months and all of the sudden does not, to my knowledge nothing significant has changed in how it works.

game.Players.PlayerAdded:connect(function(player)
	local ds = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
	player:WaitForChild("masterstats")
	wait(1)
	local s = player:FindFirstChild("masterstats"):GetChildren()
	for i = 1, #s do
		stats[i].Value = ds:GetAsync(stats[i].Name)
	end
end)

game.Players.PlayerRemoving:connect(function(player)
	local ds = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
	local ss = player:FindFirstChild("masterstats"):GetChildren()
	for i = 1, #ss do
		ds:SetAsync(ss[i].Name, ss[i].Value)
	end
end)

Your code seems to be fine. There might be something going on with Roblox as of writing this, because I am trying to publish a place to Roblox but it says an error of “Fetch Failed” and when I normally try to save to Roblox it doesn’t list my groups either.

(edit: Other people seem to be having with DataStores at the same time too…)
image

2 Likes

Strange, hopefully it gets working soon.

1 Like

Found the issue.
All I needed to do was add a BindToClose function that waits a few seconds at the end of the script, which made it work fine. I have no idea why this was needed now and not before but it works now!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.