Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Check each variable in a ModuleScript?

Asked by 4 years ago
Edited 4 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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)

0
string.match requires multiple arguments theking48989987 2147 — 4y
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)" ImperiumDomini2 39 — 4y

1 answer

Log in to vote
0
Answered by
megukoo 877 Moderation Voter
4 years ago

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.

Ad

Answer this question