Pet unboxing system and index system?

I am starting to create an unboxing system and an index system.

By unboxing system. I mean how should an unboxing system work? Should the player fire a remote event to the server where the server gets the eggs’ pets via, then selecting a random one via a weighted table, which then fires a remote event back to the client with what was unboxed to do the (visuals/unboxed pets) on the client? A remote function could easily do the same I guess, but I’m not quite sure which way of doing it is the best.

By the index system I mean if I should store a table with all eggs and pets that have been unboxed by the player to be able to show pets that have been hatched. I’m not sure if it would hit the character limit in the datastore?

local DataStructure = {
	Settings = {
		Music = true,
		Trading = true
	},
	Currencies = {
		Money = 0,
		["Eggs Opened"] = 0
	},
	Pets = {
		Equipped = {},
		Inventory = {}
	},
	Index = {
		Egg = {
			Dog = false,
			Cat = false,
			Horse = false
		},
		['Ocean Egg'] = {
			Frog = false,
			Spider = false,
			Fish = false
		}
	}
}
1 Like

I’m not sure I entirely understand your question, but I see nothing wrong with your DataStore layout. DataStores data capacity per key entry is very large, and sometime ago I read that they actually increased it even more, if I’m not mistaken.

If you could clarify a bit more in regards to the first part of your question, I can try to help you further. :slight_smile:

2 Likes

Yeah as @C_Sharper mentioned. There is generally nothing wrong with your layout. If you want to be really picky with how much data you use I guess you could just label them as this

[‘2’] = { – Ocean Egg
1 = 0, – Frog - false
2 = 0, – Spider - false
3 = 1 – Fish - true
}

and if it has a value of 0 its false if its 1 its true. But this shouldn’t even be needed to be done.

2 Likes

@C_Sharper

I might have explained it badly, sorry. I’m asking how opening eggs should be done with events (Remote Events or Remote Function) to get it to the client and to show what was unboxed back on the client.

1 Like

What I would probably do, is if the player can afford an egg, make a call to the server to buy an egg. Then, on the server, run your function that determines what egg the player will receive, add that to their data table on the server, and after you do that, you can call a remote event to that client from the server with either their entire inventory (for read-only purposes, don’t write to it obviously) or just the new egg/pet data.

I find it easier to send the client their entire inventory for rendering reasons, just be cautious not to do anything with that returned data other than rendering; exploiters might get a grip on that.

1 Like