Getting the same value across all servers

Hey there,
So I have a webhook for a shop that sends a message to discord every time something is bought and I am wanting to add a feature where it counts how many have been bought in total but I ran into the issue where the webhook will only get the value from that server and not the updated one from a different server. Is there anyway to get the updates from all servers?

1 Like

You can use DataStores. Every time player buys this thing update the value in the datastore and when sending the webhook just get the value from the datastore.

1 Like

will it update mid game though??

It will. If you update it on one server and then get it on another, the value will be the updated one.

1 Like

Oh alright, thanks ill try that

1 Like

Dont do this. You can only write on a key every 6 seconds, so when you have multiple servers it will probably break.
If you already use a webhook, then calculate it with your bot which keeps the amount of purchases. Roblox cant handle that.

They can make a queue system. Every request will be added to the queue and then they will send one every 6 seconds

You can either count with your bot itself, to increment automatically when you receive the message,
or you can use messaging service to inform all other servers and have them account for the changes.

If you mean a global universe-wide queue, that defeats the point of itself, because now you have to manage a queue using the same functionality that you could use to solve the actual problem.

1 Like

I meant a server-wide queue, not the universe-wide one.

Server-wide queues are implemented in roblox by default, and can easily break by 3 or more requests from different servers

Assuming all these players are in different servers, after player A sends a request, the key cooldown will have been reached, and then let’s say player B and C send both theirs at the same time. The different server queues will set the value to be increased by 1, when 2 players have sent the request.

Not to mention the cooldowns can grow exponentially if the requests are not rare/you manage a large game

Maybe IncrementAsync is the solution? In itself it is not a number that you put as in SetAsync or UpdateAsync, it just increases it and returns the current one, I think it would work.

Yes, but the cooldowns still remain a problem, especially in large games.

You can use MarketPlaceService:GetProductInfo(), it’s easier

https://developer.roblox.com/en-us/api-reference/function/MarketplaceService/GetProductInfo

1 Like

I think he wants to do this for non-robux purchases.

This is possible with PlayFab but that is a closed beta

1 Like

Every asset that can be obtained through a Buy/Get button belongs to the MarketPlace so even if the product is free it will have a sales value. I think he is referring to an asset that can be bought from the MarketPlace or else i don’t see why he would make this system if it’s a normal game shop.