It seems to me that technically, you could have some code in this ‘other place’ that sets boolValue.Value to false.
local function changedTheTable(table)
if not module.checkNumber(t) then
boolValue.Value = false
end
end
But it might not be a very neat place for that code, or it happens in multiple places. Indeed then technically you could use an event, such as a bindableEvent. You could do something like:
local function changedTheTable(myTable)
myBindableEvent:Fire(myTable)
end
Then you could change your earlier script like:
myBindableEvent.Event:Connect(function(myTable)
if not module.checkNumber(myTable) then
boolValue.Value = false
end
end)
function module.countDown(n, t)
if boolValue.Value then
if n == 0 then
stringValue.Value = "Success"
else
stringValue.Value = "Intermission in " .. n - 1
wait(1)
module.countDown(n - 1, t)
end
else
stringValue.Value = "Not enough players"
end
end
It’s not a very elegant or computationally cheap solution but it solves the problem at hand. Since you are writing a module, which can be imported, the correct solution would probably be to import this module in the places that change the table, and call the ‘module.changedTable’ function from there. Or better, let the module handle all the operations on the table, by calling functions in the module.
But I wanted to show you at least how a RBX event approach could work, you would have to put a bindableEvent somewhere where both scripts can grab a reference to it, it’s not a good solution. When I said ‘let events be the trigger’ I didn’t mean neccessarily an RBX (RBXScriptSignal) event, I meant it like:
When something causes something somewhere else, let that be the trigger for the response. In general, if you find yourself writing a loop that checks for a change every x seconds, then you didn’t follow this guideline, and then there is probably a better solution out there.
There isn’t a table.Changed RBX event, so a solution like that is not possible without magic functions. So whenever something wants to change the content of table t, it will have to connect to your module somehow (so you don’t ever miss a temporarily empty table t), or directly change boolValue.Value (which is less clean).
Eventually, you may want to make table t an object, and associate functions to it to set and check the contents, allowing that object to trigger game status functions in a gameManager module (which seems to be what you are working on).
But for now the task at hand is first to see what is going wrong and what must be done to fix it, then you can worry about the best or cleanest way to do it, and refactor.
I hope I got right what you wanted to do, and I didn’t spellcheck the example code. Good luck with this problem though, it’s a good problem to learn from.