#Inventory system returning nil

1 messages · Page 1 of 1 (latest)

lucid sparrow
#

okay don't judge me pls. I have tried for years to make inventory systems and I have yet to finish one, because of messyness

#

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 allatcrying

dusty garnet
#

the inventory script is the problem

winged spoke
#

bro

#

what is ts mess 😭

#

HOW DO U HAVE A MODULE SCRIPT WITH 4 ANCESTOR SCRIPTS

neat urchin
#

icl

#

this is the most extra

#

ive ever seen

winged spoke
#

IN WHAT WORLD WOULD THAT BE THE BEST ORGANIZATION

neat urchin
#

with modulescripts

winged spoke
#

sorry for the crashout

#

can we PLS

#

have something more organizated to help with

neat urchin
#

like dude just put all the coding in one or like 4 modulescripts so you dont get confused

winged spoke
#

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

winged spoke
naive siren
sterile quartz
# lucid sparrow

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.

lucid sparrow
#

I said dont judge and just look at the chat

lucid sparrow
lucid sparrow
lucid sparrow
#

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 mattersThumbs

#

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

lucid sparrow
winged spoke
#

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

sterile quartz
# lucid sparrow ty ur the only one giving me advice here. The module scripts called "Services" j...

seems like overkill since:

  1. you gotta require the module
  2. 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

winged spoke
#

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

lucid sparrow
#

I have to do Services

#

cuz I put module.Services in a variable

#

called Services

winged spoke
#

so u do Service.service 😭

lucid sparrow
#

bro what?

winged spoke
#

seccond service being like

#

UIS

lucid sparrow
winged spoke
#

RS

#

YE

#

AIUSYDGTOASTIUDAS

lucid sparrow
#

yup

#

its cleaner having them contained in a table imo

winged spoke
#

ig so crying

#

but the explorer is not clean

lucid sparrow
#

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

winged spoke
#

bro

lucid sparrow
#

its like complaining about someones aspect ratio on their screen when programming

#

it dosen't change anything except looks in the script

winged spoke
#

thats 2 more lines and 1 extra variable

#

how is that cleaner

#

but

#

meh

#

ok

lucid sparrow
winged spoke
#

?????

lucid sparrow
#

yup suprising how a table can be used to keep things more organized

winged spoke
#

but the code will be filled with Service.blalbla

#

BEING IN A TABLE DOES NOT MEAN MORE ORGANIZED 😭

#

add a comment or smth

lucid sparrow
winged spoke
#

-- Services

sterile quartz
lucid sparrow
#

local Fruits = {
Apple,
banana
}

local Cars = {
BMW,
audi,
Toyota
}

instead of
local BMW
local Apple
local Toyota
local Audi

lucid sparrow
#

its the difference between using semicolon instead of comma to seperate arguments in a function

#

or table

lucid sparrow
#

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

ruby pecan
#

Probably the most nonsense thing I even read 😭.