Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Saving custom GUI inventory objects? Help!

Asked by
if3q 6
4 years ago

I'm making a game about collecting hats and I am trying to get the hat inventory to save, and I've used many tutorials but none work! Does anyone know how to save GUI objects? Please let me know!

1 answer

Log in to vote
0
Answered by 4 years ago

From my understanding, it's not the actual GUI object that you wish to save, but rather the hats inside it. Now this is a fairly broad question, so I'm not completely certain what you mean regarding this, but here's a few cases I've come up with:

Case #1: You actually want to save the actual GUI object instead of just the hat inventory. Now you can do this through the concept of Serialization. This is how it works, Essentially, you have a GUI object, like a frame for example. Now with that frame, it has a size and a position. You'd create a dictionary within a datastore save table, like this:

local Data = {Inventory = {ObjectOne = {Size = {1,0,1,0},Position = {0,0,0,0},etc...}},...Other Stuff}

This would allow you to essentially save the properties of the GUI objects and then load then in using :GetAsync(PlayerKeyOfSomeSortUsuallyAnID) This is an extremely important concept for things such as building games, where you need to save the blocks as numbers, or in a manner which can be encoded into a JSON of some sort.

Case #2: You wish to actually save an inventory. This concept is much easier to do than the above one and this is how I'd personally go about your problem. It's fairly similar to Case one, where you'd have an array of objects, but instead of objects, it's just ID's, where you'd store the Id of a hat(by ID, you can just use the name of the hat) which was placed in ReplicatedStorage. You can then draw upon this ID whenever you wish to load the data.

If you have any further inquiries about this, please comment down below, I'll be happy to assist you. Additionally, if I've missed anything or have any suggestions, please also comment down below.

0
My inventory is a Gui where you can click on pictures of hats you have bought and it will put it on your avatar (i have scripted that and it works), but the part i need help with is to save the gui objects to show that you have the object in your inventory gui. if3q 6 — 4y
Ad

Answer this question