Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would i access this modulescript and take information from it?

So i have these Modulescript i want to take information from a localscript

heres module script:

local Strokes = 0

local module = {}

return module

heres the local script:

local ModuleScript = require(game.ReplicatedStorage.MainModule)
ModuleScript.Strokes = ModuleScript.Strokes + 1
print(ModuleScript.Strokes)

1 answer

✓ Accepted answer

The problem with your code is that you did not save 'strokes' to your table.

ModuleScripts aren't magic - they are basically functions that must return one value. By default, they return a table. What you are trying to do in your other script is access a value that is not in the table it returns.

module.Strokes = 0

But, this won't update the value when it changes, and even if it was updated, it wouldn't update the table the other script has. So, instead you use a function that returns the current value of Strokes:

local Strokes = 0

function module.GetStrokes()
	return Strokes
end

Hope I helped!

~TDP

This discussion is preserved as it was. New answers, comments, and votes are closed.