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

Check each variable in a ModuleScript?

My question is..

I have a StringValue, and the value is set to whatever a player chooses. The player can choose between a multiple of choices, and each of the outcomes are stored inside a ModuleScript, (through function())

I've taken the value of the StringValue, I just don't know where to go next.. I need to take the value of the StringValue, and have the game search through each of the values in the ModuleScript to find a match, and then execute the function that the Variable in the ModuleScript holds.

Im currently using:

local collectedSpell = currentSpell.Value
spellModule(string.match(spellModule, currentSpell))

Output: bad argument #1 to 'match' (string expected, got table)

(Most variables aren't showed, but I required the module, and other variables above that)

2 comments

0

string.match requires multiple arguments

0

Added a 2nd argument it's now "spellModule(string.match(spellModule, currentSpell))" but now an error appears in the output "bad argument #1 to 'match' (string expected, got table)"

1 answer

✓ Accepted answer

string.match takes in 2 required arguments.

The first one is the string you want to locate a match for. The second is a string representing the pattern you want to find.

spellModule appears to be the module you are using, which is a table value. currentSpell appears to be a ValueObject you are using, which wouldn't fit the 2nd argument either.

You'll need to change your first argument to the string you want to look for a match in. As for the 2nd, I think you meant to do collectedSpell.

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