Hi guys; My game saves and gets data from DataStores often; and at 4 times:

When the user joins

  • Get Data from DataStore

When the user leaves

  • Set Data to DataStore (this doesn't work for some reason though)

Every 30 seconds

  • SetAsync called for all players

When the player buys something -SetAsync when player buys more currency -SetAsync when player spends currency

However... data saving seems... inconsistent. I've tracked it down to the following error: Failure when receiving data from the peer

This error occurs in multiple scripts where data is being saved and fetched from DataStores. It happens in these scripts:

game.Players.PlayerRemoving:connect(function(player)
	if player.Playing.Value == true then
		workspace.GameStatus.NumPlayers.FinishedPlayers.Value = workspace.GameStatus.NumPlayers.FinishedPlayers.Value + 1
	end
	CoinsDS:SetAsync(key,player.Coins.Value) -- error (Failure when receiving data from the peer) here
end)

local DataStore = game:GetService("DataStoreService"):GetDataStore("Coins")

game.ReplicatedStorage.UpdateCoins.OnServerEvent:connect(function(player,coins)
	key = "user_"..player.userId
	player.Coins.Value = player.Coins.Value + coins
	if coins > 0 then
		DataStore:SetAsync(key,player.Coins.Value) -- error here
	end
end)
local GoldTrail = game:GetService("DataStoreService"):GetDataStore("GoldTrail")
local CoinTrail = game:GetService("DataStoreService"):GetDataStore("CoinsTrail")
local FireTrail = game:GetService("DataStoreService"):GetDataStore("FireTrail")

game.ReplicatedStorage.CheckTrails.OnServerEvent:connect(function(player)
	
	GTrail = GoldTrail:GetAsync("user_"..player.userId) -- here
	CTrail = CoinTrail:GetAsync("user_"..player.userId) -- here
	FTrail = FireTrail:GetAsync("user_"..player.userId) -- and here
	game.ReplicatedStorage.PlayerUpdateEvent.CheckedTrails:FireClient(player,GTrail,CTrail,FTrail)
end)

In general this seems to be happening with any Get and SetAsync's in the game. I'm not sure whats causing this. I find it hard to believe I'm reaching the request limit. Also: My game has Filtering enabled.

MD