Workspace:
game -- Workspace ---- Colours ------ ModuleScript
local Module = {} function Module.CreateValues() local Wisdom = Instance.new("NumberValue") Wisdom.Value = 5 Wisdom.Name = 'Wisdom' Wisdom.Parent = script.Parent local Bounty = Instance.new("NumberValue") Bounty.Value = 5 Bounty.Name = 'Bounty' Bounty.Parent = script.Parent local Might = Instance.new("NumberValue") Might.Value = 5 Might.Name = 'Might' Might.Parent = script.Parent local Culture = Instance.new("NumberValue") Culture.Value = 5 Culture.Name = 'Culture' Culture.Parent = script.Parent local Balance = Instance.new("NumberValue") Balance.Value = 5 Balance.Name = 'Balance' Balance.Parent = script.Parent local Marauders = Instance.new("NumberValue") Marauders.Value = 5 Marauders.Name = 'Marauders' Marauders.Parent = script.Parent local Privateers = Instance.new("NumberValue") Privateers.Value = 5 Privateers.Name = 'Privateers' Privateers.Parent = script.Parent end function Module.DrawCard() local Random = math.random(1,7) -- Creating a Switch-Case local Factions = { [1] = 'Wisdom', [2] = 'Bounty', [3] = 'Might', [4] = 'Culture', [5] = 'Balance', [6] = 'Marauders', [7] = 'Privateers', } print(Factions[Random]) script.Parent.Factions[Random].Value = -1 end function Module.Regenerate() -- Remember that Folder is actually Colours ;3 local Folder = script.Parent Folder.Wisdom.Value = 5 Folder.Bounty.Value = 5 Folder.Might.Value = 5 Folder.Culture.Value = 5 Folder.Balance.Value = 5 Folder.Marauders.Value = 5 Folder.Privateers.Value = 5 end return Module
Whenever I invoke the module's functions with:
local InvokeFunction = require(game.Workspace.Colours.ModuleScript); InvokeFunction. Module.CreateValues()
It reports with
local InvokeFunction = require(game.Workspace.Colours.ModuleScript); InvokeFunction. Module.CreateValues():1: attempt to index field 'Module' (a nil value)
Why is that? How can I use the command bar to call/invoke functions defined in a module script?