Global Variable within Module Script

So I have a module script with a counter that gets added to over time.
I want all scripts which require the module to read the counter and be given the same number.
In my testing scripts that require at about the same time return the same number, but those that require at a different time return a different number.
I need the counter number to be the same for all other scripts since some functions rely on the accuracy of their number.

And so I’m wondering if there is a way to store this counter number so that all scripts which require the module, regardless of when, will read the same number.
I figure otherwise I can store this counter as a Value instance or an Attribute.

2 Likes

You need to use an object value. A simple int will do fine for your case since you are counting whole numbers, but if you want higher accuracy, you will need a decimal. Simply right-click > insert new instance > pick the object value you need (search for int, number, etc.) and insert it. Set the default value, and use that object in your scripts. As for global variables, those are only available in server scripts; modules can use them if they were called from a server script but can’t in a local script. More about that here: