This might seem daunting at first, but really if you break it up, it seems more manageable.
- Figure out how to communicate between servers
- Save data such as that.
How to communicate between servers
ROBLOX has a neat little API which isn’t talked much, where you can talk between different servers. This is typically how games such as “Perris, California” have server lists where you can join.
This is called MessagingService
You would use MessagingService:PostAsync(topic, message)
to post a message between all servers, and then create a function that listens for that message
local connection = MessagingService:SubscribeAsync(topic, function(message)
print("Received message for ".. message.Data .." in topic: "..topic)
end)
The topic can be anything. Imagine these are news articles which update whenever
The “Topic” is just the title of the news report.
The “Message” is what actually is within the news report.
Save the Data
The game would listen for a specific topic, e.g. playerBoughtAProduct
And then the message could be a table, which could look something like this
print(message.Data)
{
["Buyer"] = "ILoveBuyingPeopleThings",
["Recipient"] = "PeopleBuyThingsForMe",
["Product"] = "LazerGun"
}
Once the message is received, the server would first check whether the recipient is within the server.
If the player isn’t, then it is ignored, because the player isn’t in the server.
If the player is in the server, then give them the product.
To do the offline check, you could create a secondary topic, where only if the product is given, then send a message to the topic, could be called playerReceivedProduct
.
This will be received by the original server (add like a wait time of around 5mins). If the original server (where the player actually bought the product for someone else) did not receive anything about playerReceivedProduct, then perhaps manually edit the recipients datastore with a new variable called giveOnJoin
, and when the player joins, they automatically get it, and the datastore value is erased.
This might seem longwinded, but hopefully it works! If anyone has any other recommendations, just let me know.