Provided Universe Isn't Valid? (Datastore)

I was testing my games datastore due to some reports of data loss and I came across this:

error: "DataStoreService: InvalidUniverse: The provided universe is not valid. API: GetAsync, Data Store: database "

Now, when I played again it worked so I couldn’t see this error but luckily I was able to copy and paste it. I’m just really confused on what this means and I feel this may be the source of the problems, the game just uses like the default roblox DataStore (didn’t know abt ProfileService at the time :sob: )

If anyone knows what this is and how to solve it, please feel free to let me know as I have no idea on what this means, I’ve never gotten this error before… Thanks!

1 Like

For more reference, here’s my save data function:

local function saveData(player)
	print(player)	
	if data[player.UserId] and player.UserId ~= 0 and isLoaded[player] == true then
		local success = nil
		local playerData = nil
		local attempt = 1

		repeat
			success, playerData = pcall(function()
				return dataBase:UpdateAsync(player.UserId, function()
					return data[player.UserId]
				end)
			end)

			attempt += 1
			if not success then
				warn(playerData)
				task.wait()
			end
		until success or attempt == 3

		if success then
			print("Data saved successfully")
		else
			warn("Unable to save data for player", player.UserId)
		end
	else
		warn("No session data for", player.UserId)
	end
	isLoaded[player] = nil
end
Players.PlayerRemoving:Connect(function(player)
	saveData(player)
	data[player.UserId] = nil
end)

game:BindToClose(function()--if game shuts down
	if not RunService:IsStudio() then
		print("Shutting down")
		for index, player in ipairs(Players:GetPlayers()) do
			task.spawn(function()
				saveData(player)
			end)
		end
	else
		print("Shutting down inside studio")
	end
end)

And the loading looks like this:

local function loadData(player)
	print(player)
	local success = nil
	local playerData = nil
	local attempt = 1

	repeat
		success, playerData = pcall(function()
			return dataBase:GetAsync(player.UserId)
		end)

		attempt += 1
		if not success then
			warn(playerData)
			task.wait()
		end
	until success or attempt == 3

	if success then
		
		if not playerData then--give default data if they're new
			playerData = {
				["Gems"] = 0,
				["SelectedTowers"] = {"Cameraguy"},
				["OwnedTowers"] = {"Cameraguy"},
				["MaxTowers"] = 5,
				["RedeemedCodes"] = {},
				["Wins"] = 0,
				["Snowflakes"] = 0,
			}
		end
		
		data[player.UserId] = playerData
		isLoaded[player] = true

Thing is, I don’t remember changing it (only thing I changed was adding the isLoaded after reports arose but they’re still not solved) but data loss reports arose all of a sudden so I’m quite confused if this is an issue with the code or an issue with roblox servers.