I get warnings of data store queue filling up for specific keys, and then after a while it says it errors
I’ve read the documentation, and there 2 players in the server so to my understanding
numPlayers = 2
60 + numPlayers × 10
So to my understanding, that means I can have 80 Set requests a minute. There was no way I was exceeding that, and can see in the SS that the console doesn’t have 80 requests (probably only around 40 or so), yet it still throws warnings at the bottom saying data isn’t saving.
Is there anyway to optimize this, as 40 requests in a short period of time seems pre bad. I added a debounce on the client (this function below is fired on the server when a player clicks a button) and that debounce will hopefully prevent spam clicking, but I know exploiters can spam the remote event anyway, however, they wouldn’t be able to get far unless they entered a User that is in their friends list name.
local function MessageSent(player, sendingTo, message)
-- Get player sending to
local RecipientID
local Success, Error = pcall(function()
RecipientID = Players:GetUserIdFromNameAsync(sendingTo)
end)
if not Success then
return 'Player does not exist'
end
if not RecipientID then return 'Error' end
-- Make sure player is friends with RecipientID (can only send messages to friends)
if not player:IsFriendsWith(RecipientID) then return 'Error' end
local FilteredMessage = Chat:FilterStringForBroadcast(message, player)
local Data = GetData(RecipientID)
if Data then
table.insert(Data['Messages'], FilteredMessage)
local TryCount = 0
local Success, Error
-- Save data
repeat
Success, Error = pcall(function()
DataStore:SetAsync(RecipientID, Data)
end)
TryCount = TryCount + 1
until TryCount >= Tries or Success
-- Failed to save
if not Success then
warn('Data failed to save | Error Code:' .. tostring(Error))
return 'Error'
end
if Success then
MessagingService:PublishAsync('Messages', {Message = FilteredMessage, Sending = player.Name, Recipient = sendingTo})
return 'Sent!'
end
end
end
I can’t do any saving when player leaves with this either, as this is made to change player data whether or not they are in the server