Writing into a table works once, yet not twice

Currently, I have a script (i’ll call A to make this explanation more straightforward) that calls a module (B) with a function that connects a ClickDetector mouseclick to its own event (still inside of B but ran by A) that writes into a table in the arguments of A so that later on in a RunService loop, in A, it can check if B has written into this table.

The problem is, A does seem to see the changes to the table the first time B writes into the table, but when it tries for a second time it wont…? when I refresh this table in A so that the table is empty the next time it is checked, so that the same Instance isn’t acted upon twice, for some reason this stops B from writing into the table?

B is passed the table (highlighted) from A in this parameter:


and is also cleared at the end of the click event so that the table is new each time the event runs
image
one thing to note is that the print line above does show that B sees the table as containing what it has written by itself by the end of the function.

In A, the table is placed into the parameters here:


and checked if containing anything here:

as said earlier, the Output does tell me that B is writing into the table, however A only notices this in its loop the first time?
image

finally, not resetting PendingUpdates (the table) in A DOES let it respond immediately to these alterations made by B, but obviously I would prefer the code to run only once when needed, rather than every single loop…

please lmk any further details that may be necessary in bugfixing this but right now these seem to be the most important portions

1 Like

(bumping due to the amount of posts i see above mine already answered somewhat)

bump for similar reasoning, if you stumble across this post and decide not to answer please lmk what i should change to make this easier to get help with

poorly articulated and very hard to understand… anyway if i understand this right your problem is that the A script does not notice B writing into the table?
But isn’t that because you’re resetting the table on the module script, and so the check if #PendingUpdates > 0 doesn’t go through because it’s already empty

yeah i wasnt really sure how to describe it correctly because its alot of intertwined parts lmao

sir yes sir

i mean i thought this was the case too but the original script responds the exact same even if i remove that line, and then the modulescript seems to cache a different version of the PendingUpdates table where it constantly adds onto the last table from the last click event

not related to the quotes now but as for now i moved all the functions out of the modulescript and into the script itself, and it is working (albeit with some modifications) however i would still prefer to move it back into the modulescript simply because of how much space the functions take up in the script lmao

try returning the table in the modulescript function and setting its value in the script:

PendingUpdates = DeviceFunctionsModule[Device.Name](Device, RegisteredDevices, PendingUpdates)

sadly i dont think this will work as the part which writes into the PendingUpdates table is in a click event inside of the function called by the script

anyone else able to help us with this? im trying to find a way i can send back a table of models whenever a click event is fired, that has been connected within a modulescript, to the script running the function