Cross Server Communication

So lets say a player hatches a pet. Pet is a secret. And there is a table which holds a bunch of string values of all pets. I can get the table and find number of the pet being hatched. How should I do this?? I am very confused to find number of pet hatched across all servers and then saving.

I tried Trello but Trello has limits so I need something else.

4 Likes

Not too sure but MessagingService might be what you’re looking for

2 Likes

That doesn’t save anything…

Save it in a DataStore instead?

Also, why are you overcomplicating things? Just put the table in a script (server-side not localscript), which would be the same for every server. Something like:

local pets = {
    pet1 = ...,
    pet2 = ... 
}
1 Like

It isn’t clear what you’re trying to achieve. Are you trying to count how many pets everybody has hatched in total? How many pets one player has hatched? Saving data about the pets in general like the string values of all pets? Please be more specific and it will be easier to help you.

1 Like

I am not trying to find what ONLY the player hatched. I am trying to find across all servers. Like a table across all tables.

I can do discord Webhooks. but Total Hatched part I am not able to figure out.

Use DataStoreService, increment a totalhatched value, send that to your discord webhook or whenever else you want that.

Please read the developer-hub before asking about easy to find services.

Try saving each player’s pets individually in a datastore then loading said datastore when the player joins a game. I would not recommend sending data across all servers because if the player joins a fresh server, the server will not have the player’s pet data stored and thus resulting in the player not receiving his or her pet.
A method to saving the player data would be to keep a table of pets they have stored saved in a datastore and then when they join the game, use a for loop to go through the table and give them the pets.

I am not trying to do this for one player. If I needed one player I wouldn’t make this post. I need to make a global table where each time someone hatches a secret pet you can add a string. I can also get the Table.

You don’t have to use datastores for players? You can just make a datastore with a value in it that can be changed. Datastore key values never have to be playerids:

local DataStoreService = game:GetService("DataStoreService")
local PetData = DataStoreService:GetDataStore("PetData")

function incrementPetData()
    PetData:IncrementAsync("TotalHatched", 1)
end

function getPetData()
    return PetData:GetAsync("TotalHatched")
end

Or if that isn’t as real-time as you want it, you can write a webserver and store the data externally

4 Likes

I think you can use ordered data store for this, where each key is the pet name or whatever and the value is the time that it was opened. The issue with normal data stores is that it would be practically impossible to always access the same key due to data store limits and I think it would be difficult to use different keys to store each hatch event.

Even with an ordered data store I think you’d probably run into issues trying to get all of the information in it if there’s a lot of players.

Use a DataStore for this, you can make the key the name / index of the secret pet and then the value a table of all UserIds that have hatched it. Or something along those lines. Then you can simply do a get request to get the table of all players who hatched a specific pet.

DataStore?

Everytime a player hatches a Mythical, you add to datastore the amount of mythicals hatched total.

So, if Bob in Server A hatches a mythical, your game checks the DataStore and then tells Bob what number mythical it is total and updates the store.

Then, if Billy in Server B right after Bob hatches it hatches a mythical, it checks the DataStore and etc.

My module lol :flushed: I’m not so sure here, but there’s like DataStore.OnUpdate(), I never used it but I know it exists;

OnUpdate is broken and deprecated. You have to poll DataStores for OnUpdate to work which is unnecessary consumption of your per minute DataStore request budget. A combination of DataStores and MessagingService needs to be used here.

1 Like

I guess my module could work here then, though it is on beta and I literally just pushed out an update that shouldn’t be most stable right now, it should work; Though I think his system isn’t the same thing, anyway this is confusing lol

OP’s question has been answered several times for them, so at this point a solution should already have been marked. Cross-server communication is done with MessagingService and tracking the total amount hatched in the game’s lifetime is done with DataStoreService. It’s unintuitive but required. So I’m not exactly sure where OP is still having trouble.

This can be done with MessagingService in a way that it can help not have as many Datastore Requests just because someone opened an egg. You could have a request system using Messaging Service, which checks how many eggs were hatched on datastores, and then send a request to all servers to return how many eggs were opened ever since the server was open, then on BindToClose() you could increment a sync to add the hatched eggs on that server; anyways it’s hard to explain

Basically new servers would count how many eggs were hatched on that specific server and then you can Increment them once the server closes. Also there’s the fact that you can use Messaging Service as a way to ask all servers how many were hatched on them;

He’s trying to calculate how many eggs were EVER hatched since literally forever, for that he CAN use messaging service as a way to cache stuff, and then everything I said above and yeah.

IHow do I do this with a string?