Roblox servers can handle 60 + (user amount)*10 requests per minute. Sending one per minute is not as bad as you’re making it out to be.
And in any case
It applies specifically to MemoryStores due to their design. They are not persistent.
If the score doesn’t need to be persistent, then indeed MemoryStores are the right choice.
The persistence is between sessions, not between reading the store values.
You mentioned the requests that Roblox servers can handle. The data request queue is different to the amount of requests a server can handle per minute, so it’s not really about that. The data queue is a queue of data store requests that has a certain capacity, exceed this capacity and further requests are dropped. The request limit, which is what you are talking about, is how many requests the server can handle before an error is thrown. In this case, the request does not go through at all, contrasting to the queue, where requests are merely dropped if it fills. Using a data store is less reliable for a system like this and it will also interfere with other data store operations by eating down the data request budget, which causes other requests to be throttled and dropped more often, which can be a major problem for things like player data. When you talked about data persistence, that’s just the ability to retain data across sessions, which in that case you should write it to a data store when the server shuts down and retrieve it when it restarts. That way, you retain the score’s persistence whilst minimising the impact on other data store requests.
In this scenario, MemoryStoreService has lower latency, whilst also literally being built for things like this. Why do you want to only use DataStores, a system that isn’t built for something like this and would generally be not recommended, when you can use a mixture of both to get the best results?
Yes, that’s why I suggested using MemoryStores with DataStores together. But to make it simpler, you can just use DataStores and not care about the amount of requests and stuff.
Anyway, we’re not really adding anything to OP’s problem, so I suggest we stop arguing here.
You did not suggest this. You suggested only data stores. I’d like to stop this argument now, since memory stores and data stores pose an efficient solution to the OP. You’ve just implicitely told me persistence is not between sessions, after I previously told you it was.
Anyway, I made this post to clear up a few things that the OP may have got confused about from reading this argument:
Memory stores are not persistent. We can combine them with data stores to preserve data across sessions.
Memory stores are used for smaller pieces of data that update often, such as this.
Data stores are used for storing data that updates less frequently and needs to persist across sessions.
You could use a RemoteEvent to allow a players actions on the client side and to safely communicate with the server
ServerScriptService Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateGlobalCounter = ReplicatedStorage:WaitForChild("UpdateGlobalCounter")
local DataStoreService = game:GetService("DataStoreService")
local MessagingService = game:GetService("MessagingService")
local globalScoreStore = DataStoreService:GetDataStore("GlobalScore")
local GlobalCounter = workspace:WaitForChild("GlobalCounter")
-- This retrieves the score when the server starts
local success, globalScore = pcall(function()
return globalScoreStore:GetAsync("GlobalCounter")
end)
if success and globalScore then
GlobalCounter.Value = globalScore
else
GlobalCounter.Value = 0
end
-- This listens for RemoteEvent to update the score
UpdateGlobalCounter.OnServerEvent:Connect(function(player, incrementValue)
GlobalCounter.Value = GlobalCounter.Value + incrementValue
-- Save the updated value to DataStore
pcall(function()
globalScoreStore:SetAsync("GlobalCounter", GlobalCounter.Value)
end)
-- Broadcast the new score to other servers
pcall(function()
MessagingService:PublishAsync("GlobalScoreUpdate", GlobalCounter.Value)
end)
end)
-- This sync with other servers
MessagingService:SubscribeAsync("GlobalScoreUpdate", function(message)
GlobalCounter.Value = message.Data
end)
Make a LocalScript inside the TextButton that players can click. The script sends a request to the server to update the score.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateGlobalCounter = ReplicatedStorage:WaitForChild("UpdateGlobalCounter")
local button = script.Parent
button.MouseButton1Click:Connect(function()
UpdateGlobalCounter:FireServer(1)
end)
I am not a great explainer so sorry if this confuses you but I hope this helps!