So I’ll give some context. In my game I’m working on I’m going to have have a shop that players can buy skins for their weapons from (actual models, not just retextures). These purchased skins will then go into a player’s inventory where they can be equipped and unequipped.
In the game there’s 5 rarities, each weapon skin is assigned a specific rarity. I want to be able to store the image for the skin, the rarity & price, and the skin itself all in one place.
What would be the best way to store all of these skins in a centralized place where everything can access it? (The shop, inventory, and the player’s Hotbar for equipping).
What would be the best way of executing this? I’m fairly new to scripting (started in mid March) so I don’t know if my idea would work.
Could I use a dictionary to store all the values such as rarities, imageid, price, and also the model? If so how would I access the dictionary in other scripts?
Or could I use ModuleScripts in some way to store all the info? My knowledge on module scripts is pretty limited.
Is there a better way to do this? Let me know!
2 Likes
Okay I found out I can make a dictionary inside of module scripts. So would I be able to access everything in other scripts just fine? Say for example when a player buys a skin from the shop and it goes into the inventory. How would I make the rarity, image id, price, and model all load as a new button inside the gui?
if you are using an object use replicated storage so you can clone it from there.
module scripts are typically used as tables in a separate script and normally just for organization.
there is probably other uses for module scripts other than organization but I can’t think of any examples.
edit: just understood what you meant. yes you can use module scripts for that and i would highly encourage you to use a module script for the organization as it is a good habit to get into and could help you code more efficiently.
edit 2:Now fully realizing what you meant. use replicated storage to make the rarity, image id etc. and copy it from RepStorage to where you want it to be.
1 Like
Awesome, would it be as simple as cloning the table of info for that specific cosmetic? I’ll make an example of a table within said dictionary
[“Fire Sword”] = {
Name = “Fire Sword”;
Type = “Sword”;
ImageId = 12345678;
Rarity = “Legendary”;
Price = 1234;
};
[more tables for cosmetics would be present here]
So I have 3 questions. 1) How would I store the model itself within the table? 2) Every rarity has a specific price. So for example all epic rarity items are 800 currency, all legendary are 1200, etc. Is there a way I could save time and not have to write out all the individual prices for the cosmetics and have it linked to the rarity? 3) How would I make a cosmetic appear in a player’s inventory with all the information? Would it be as simple as cloning the entire table for the cosmetic into an inventory table or would I have to clone each individual thing within a cosmetic’s info table?
From what i understand you are saying, no you do not have to individually clone the properties of the objects within the module script and it is not possible to store a model within a module script you must use a variable in a local or server script but you can do
local ModuleScriptExample = require(location of the module script)
this will make it so you can use the objects within the table
you can also put functions in there as they do here → ModuleScript | Roblox Creator Documentation
and as you are saying here i don’t completely understand but what i do understand is that you could probably just clone the entire table.
1 Like
Could I make a folder of all the models then in the tables make variables? So like FireswordModel = game.replicatedstorage.ModelFolder.fireswordmodel?
I’ll explain what I said earlier. So basically every cosmetic has a rarity, price, name, etc. When a player buys a cosmetic from the shop I want it to appear into the inventory with all the information from the table (rarity, name, etc). How would I make all the information appear?
when you say appear do you mean visually or they are attributed to the object? and yes you can use a folder.
So you see those glows? Those indicate the rarity. Then in the store you have name, price, image Id and item type.
In the inventory I want all of this info to transfer over and display (besides price ofc). So name, rarity, etc. Item type doesn’t matter since they’re being stored in seperate tabs in both the shops and inventory. For example Sword Tab in Shop, Sword Tab In Inventory - Axe Tab in Shop, Axe Tab in Inventory.
How would I go about making it so all of this appears? For the glow itself I was just going to make it part of the image for the weapon itself for simplicity’s sake.
1st off i wanna say that this is roblox bedwars and i wanna point that out because they have developers that can make some complicated scripts and when someone wants to do the same there is an issue because it is too complicated for people to figure out how to make.
as per your request i am understanding you want a gui to pop up showing the names of the attributes of the item being held, am i correct or no?
I’ll explain in further detail. The Bedwars gui was just an example of inventory layout. Categories for the specific things, name, image, and a color indicating rarity (idk if that part is true, I don’t play the game much). So I’ll explain what I’m trying to achieve. So, we have our module script with tables for every weapon. These tables store all the info such as name, rarity, etc. So what I’m wanting to do is have it so when an item is cloned into the inventory after purchase it makes all the info display as gui. So for example let’s say I have a BlueSword in the shop that’s legendary rarity. When that BlueSword is purchased I want it to appear as a box in the players inventory. Within that box I want it to display the image for the BlueSword, the rarity glow I mentioned, and the name. How could I go about achieving this?
Ah so an inventory system. you can use roblox’s default inventory system and have it delete any extra items when the inventory is full.
I have a custom inventory system in mind. What I’m wondering is how to have said stuff display when cloned? So for my example how would I have a new box in the inventory that says BlueSword, the image of the sword, the legendary rarity glow, and the name. Is there a system I could make for this?
yes just use an image button, text button, and if you are trying to only have the glow happen when it is selected then another image button around said selected item. also it isn’t called a box it is called a tool if you were wondering.
I’ll show you what I mean. See those boxes in the title inventory? Basically I want a system like that. So when an item is bought and cloned from the shop it’ll display the image, name, and rarity glow. What I want to know is how to achieve this. Like how do I make it so that specific gui appears when cloned?
1st off i can tell u are on an ipad just wanted to point it out has nothing to do with anything.
2nd off, are you asking me to make the script for you?
Yeah I use an iPad for literally anything besides studio itself or gaming lol
I’m not asking for you to make a script, I’m asking how I would make the stuff I mentioned appear in the inventory?
oh thats easy. just insert an image button by clicking the ‘+’ next to StarterGui or any other object and then type image button and text button.
Actually I figured out a way to explain this better. So we have our tables for info on individual cosmetics right? What I’m asking is when I clone a cosmetic into the inventory if there’s a way to translate that info to gui. So when it’s cloned it displays all that info in a gui. So I’ll walk you through. Cosmetic is cloned to inventory - new box is created for cosmetic in the inventory - the script checks the name of the cosmetic in the table and displays it in said box - the script checks the rarity of the cosmetic in the table and display a rarity glow in said box - the script checks the imageid of the cosmetic in the table and displays the image inside said box. What I want to know is how I achieve this system? Like how do I translate the information into ui?
GuiService | Roblox Creator Documentation this shows how to set the message for the text button
this is the same thing only for the image button → ImageButton | Roblox Creator Documentation
There are a few ways I can think of to achieve this.
Do you already have a way of detecting when a cosmetic is added to the inventory?