hi, im not sure why this doesnt work. I have another script printing the value of time every 0.2 seconds, and have a click detector using module.setTrue() . My click detect works fine, but after i click it, my first script is still printing that “tim” is false.
note that no errors are thrown and my first “tim printing” script is a local one, but i have put the module script in replicated storage , so it should be able to use it
local module = {}
tim = false
function module:setTrue()
module.tim = true
print(module.tim)
end
function module:getTim()
print("tim", module.tim)
return module.tim
end
return module
Module scripts are quite straightforward. Y
They are basically rental functions. Anyone can use them to do whatever they want with them.
That means that they borrow the behaviour from what calls them. A localscript calls a module: the module behaves like a localscript.
So you can think of it like this: every client has a module of their own, and the server has one too. Like a local database. You need to be consistent with the place where you’re calling the module from throughout the game if you want it to function the way you want it to
That’s the problem only in case of using module:getTim() function because there’s no child with index tim in the table, so it returns nil instead of false.
You’re absolutely right that, it should be declared in the table before functions, but maybe the actual problem here is that he tries to index table changes on different sides, which is impossible
You can add a function to your module, print function. It will work if you call it from the same client/server. But it doesn’t change the behaviour of the modulescript at all. You should still keep in mind the server replication stuff