#Inventory system returning nil
1 messages · Page 1 of 1 (latest)
discord wont let me send code for some reason so I will just send txt files
the local Modules are:
PromptService
PromptsDef
InvUI
the server modules are:
InvManager
Constructor
the server script is:
Inventory
yes ik it's messy and that is why my brain is liquid
its totally understandable if you don't wanna read allat
the inventory script is the problem
IN WHAT WORLD WOULD THAT BE THE BEST ORGANIZATION
with modulescripts
like dude just put all the coding in one or like 4 modulescripts so you dont get confused
u literally have 5 module scripts named Services 🥀
To be honest
i dont think u should work in a inventory system just yet
it uses a lot of table knowlage and organization
so imo u should firstly work on a better organization of the explorer and the scripts
try to avoid multiple scripts that could just be 1
(specially module scripts)
there's 7 😭
Kinda bad practise to have module scripts under a local script and under server scripts. Usually what I do is have one local script then store the rest of the module scripts inside replicatedstore for client side and for server side modules keep in serverstorage. Also as others have mentioned you have multiple scripts with the same name. They probs server different purposes but u should aim to try and merge some modules scripts or make them simpler.
I said dont judge and just look at the chat
yeah each of them contain the services that only that module will use
that would make me more confused when each modulescript is 4k lines long
I NEVER SAID THAT
I said it was messy bro
I know
that's why I can't make it, because I get confused by the tables
anyways I got it working
so yall can stfu
here
I improved it even more tho so now you can drop items
and fixed some bugs
ik it's not bulletproof and adding new shit takes a while, but idk as long as it works (kinda) thats what matters
and I'm proud I somehow managed to have this mess and make it work
what the service script is
it littearly just returns a table of services
it's cleaner than having it inside the script imo
ik I can just use one, but then I need to instance it everytime instead of just "script.Services"
thats just preference
ty ur the only one giving me advice here. The module scripts called "Services" just return a table with the services
u know
that
after a update
u can set your own custom presets
so
uhh
when u create a script
u can set the preset to instead of printing hello world
a game:GetService() of sum services
same for parts or any instance
u can set presets to almost anything that is addable
seems like overkill since:
- you gotta require the module
- you gotta use a module instance which makes ur explorer cluttered. (I think theres also a performance cost but im not entirely sure here)
Also forgot to mention you should try decoupling ur logic so dont child InvData under Constructor for example. I think what would be a good idea is to separate ur logic scripts and ur gui scripts. So if u want to drop an item the main script will notify the server to drop the item and then it will notify ur gui script to update the gui. That way u dont have the gui handling logic and script logic in the same script.
This website is pretty useful since u can use the observer pattern so that u dont even need to call ur gui scripts manually they get updated whenever u make a change in ur main logic script. https://refactoring.guru/design-patterns/observer
i dont get this part
like
u r creating a module script and then writing everything u would write on a normal script
and then using require
so u have to do module.Service
instead of just
Service
I dont have to do module.Service
I have to do Services
cuz I put module.Services in a variable
called Services
so u do Service.service 😭
bro what?
I do Services.RS for example
like instead of
local RS =
local SSS =
local UIS =
I would have it like this
local Services = {
RS =
SSS =
UIS =
}
it dosent change anything logic or systematic. It is more of a preference thing
bro
its like complaining about someones aspect ratio on their screen when programming
it dosen't change anything except looks in the script
its cleaner because now the services are sorted in a table
?????
yup suprising how a table can be used to keep things more organized
but the code will be filled with Service.blalbla
BEING IN A TABLE DOES NOT MEAN MORE ORGANIZED 😭
add a comment or smth
yes it does
-- Services
Yea I mean if thats what u prefer go for it since its ur game but if ur gonna use a module for services at least make one general and not 7 that are randomly embedded in each script
local Fruits = {
Apple,
banana
}
local Cars = {
BMW,
audi,
Toyota
}
instead of
local BMW
local Apple
local Toyota
local Audi
yeah exactly its a more preference thing
its the difference between using semicolon instead of comma to seperate arguments in a function
or table
commenting can be used aswell to organize. That is also considered a preference thing
dosen't change any logic
just makes code easier for other ppl to read
but considering my code is beyond human understanding I don't feel the need rly
anyways my primary reason for this post was for help, but that seemed to not work
fixed the problem myself after about 6 hours of troubleshooting
so I think I'm closing the post
Probably the most nonsense thing I even read 😭.