Instances (IntValue, StringValue, etc.) or Dictionaries for Tools

I have a question in regards to tools. So if you were to make a shop gui and implement tools and their costs and maybe other stats such as damage, would it be better to have StringValues and/or IntValues hold those information under the tool and refer to that or would it be better to have it in a dictionary and refer to the dictionary instead?

For example:

-- Possibly have this in a nested dictionary named tools (if possible)?
local sword = {
    ["Name"] = "Sword";
    ["Cost"] = 250;
    ["Damage"] = 25;
}

Sorry if this isn’t how to properly do it, as I am new and learning how to work with dictionaries currently.

I would assume that maybe using dictionaries would be more effective as tools are usually in ReplicatedStorage (from what I’ve seen so far) and I believe ReplicatedStorage is open to the client and server? Correct me if I’m wrong. I rather get answers from people who actually know rather than taking a guess.

Any feedback is appreciated! :grin:

Those methods are all compatible with what you’re trying to achieve. Personally, I feel values would be more convenient, but it’s really up to preference. If you have an IntValue/ StringValue for each tool, then you could just loop through the tools and show the information, as well as directly reference them, which is still possible through a dictionary.

It’s really up to preference. I prefer values because it’s convenient in terms of flexibility and is quite straightforward.

Yes, however any changes from the client will not replicate to the server or other clients. Personally, I would just store my tools in ServerStorage.

Edit:
I had to add that for some users, ValueObjects may feel redundant and there may be high dependency on the location of your value objects, so in this case dictionaries may be a better approach.

Sorry if this isn’t how to properly do it, as I am new and learning how to work with dictionaries currently.

Seems like a great chance for you to utilise dictionaries :wink:

1 Like

Thank you very much, this gave me lots of in-sight. :grin: