So I have a table of words, these words correspond to a model in-game. The idea is the player can say "regen ..ModelNameFromTable" and that model will regen.
RegenModule = require(game.ServerScriptService.RegenModule) local Models= { "ModelTest", "Model", } function onChatted(msg, recipient, Player) msg = string.lower(msg) if (msg == "regen"..Models.ModelName) then RegenModule.Regen(Player) end end
As you can see I put an example here "if (msg == "regen"..Models.ModelName) then", but obviously this does not work.
Also, it would have to carry over as an argument to the ModuleScript, as that's where the main script is located.
Here's an easier way that works:
game.Players.PlayerAdded:Connect(function(player) game.Players[player.Name].Chatted:Connect(function(msg) if msg == "Your Phrase" then -- Your code here end end end
Please put [SOLVED] in your title if it helped and leave me an Upvote :)
Managed to solve my own problem, just took some trial and error.
RegenModule = require(game.ServerScriptService.RegenModule) local Models= { "Model", "Model2", } function onChatted(msg, recipient, Player) msg = string.lower(msg) for index = 1, #Models do local value = Models[index] if (msg == "regen"..value) then RegenModule.Regen(Player, value) end end end
This worked perfectly, and I can use the value as an argument for my ModuleScript.