Well, the title is pretty self explanatory, but I'm probably doing something wrong for stupid -_-, but anyways, the module script that has a table in it won't print the number of values. It just prints 0.
--- Module Script --- local module = {} -- I'm too lazy to change this module.turntable = {} wait(10) -- You will know what this is later print(#module.turntable) -- It prints 0 instead of 2, because as you can see below, there is a 9 second wait, then it adds another variable to the table return module
Local Script
---This script has other stuff in it, so I'm just gonna put the part that matters here--- local turntablescript = require(script.Parent.Turn) table.insert(turntablescript.turntable, "Player 1") -- I actually have it set up to put the actual player's name, but that's referenced earlier in the script, and as I said before I'm not adding that print(#turntable.turntable) -- BTW this works wait(9) -- This is where the wait 10 comes from earlier table.insert(turntablescript.turntable, "Player 2")
If I were to have the local script print how many variables are in the table, it would work, but whenever I try to print it from the module script, it only prints 0, even if there is a variable in a table.
Your script is working perfectly. The script will yield until the module script has finished. This means that you cannot add items to turntable while the wait is yielding. So, you are really printing before adding to the table. Here is what the progression looks like:
module script is required
then
turntable is created
then
wait for ten seconds
then
print turntable length (should be zero)
then
insert "Player 1" into turntable
then
print length (should be one)
then
wait nine seconds
then
add "Player 2" to turntable
then
If you were to print the length here, it would output 2. I hope this helps. Have a great day scripting!