How to create stock pet eggs?

I bet you’ve seen stock pets like these before
image

I’m trying to create that in my own game but i don’t really know how i would script it.
I know something about having to use datastoreservice to save it.

1 Like

Use google to search what you want, try different queries sometimes. Here is what I found from a simple query on “create a pet system roblox”.

you said it it’s using DataStores. You Store a value under the key Florale or something like that which starts at 500 and you update the value everytime a player buys it. When it hits 0 they can’t buy anymore. The Gui would have to update every like 5 minutes to how many copies are left

1 Like

Hey. I do like this idea of using datastores, I mean yes you have to store it somewhere. I don’t totally like the idea of updating it every 5 minutes, as it isn’t a live update, could have a delay, and that could also become a lot of :GetAsync() Calls. (Players like the feel of a live countdown as it feels more ‘real and limited’ and like that you have to get it now)

If you had extra time, I would consider adding the MessagingService as you wouldn’t have to call Datastores every 5 minutes. Also gives players a live countdown, and inside the message argument you can mention the amount of stock. That way you would only need to use UpdateAsync() in Datastores when changing the value, and then tell all servers this new value. You would need One :GetAsync for sure, and that is when the server is starting up!

Only issue with this idea is MessagingService has limits. Depending how big your game is, and how many players it takes to fill out a server, you may have issues with the limit of how many messages you can send etc. This shouldn’t be an issue if the pet is hard to get, or if your game is popular as the limits increase with the more users/Servers you have. Also to note, MessagingService is a best try, and not guaranteed, meaning that you should still check if you don’t get a response within the same topic within a certain time frame, and check via datastore to make sure the number displayed is true. (this could be because no one has gotten the pet within that time frame so no message was Sent to the servers with a Updated Number, or it could be because there were messages but the server didn’t get them!)

The limits of MessagingService Include
Limit Maximum
Size of message 1kB
Messages sent per game server 150 + 60 * (number of players in this game server) per minute
Messages received per topic (10 + 20 * number of servers) per minute
Messages received for entire game (100 + 50 * number of servers) per minute
Subscriptions allowed per game server 5 + 2 * (number of players in this game server)
2 Likes