I know the title is a bit confusing, but I couldn`t think of any good name. Anyways, what I want to ask is, is there any way to refer to properties or function by string? For example, I have a module script that contains this:
local module = {} function module.blah1(bool) if bool == true then print("Blah1") end end function module.blah2(bool) if bool == true then print("Blah2") end end return module
And the normal script will require this when Player Fires RemoteEvent.
local blahModule = require(script.ModuleScript) local function printBlah(plr,actionName) --This Part Will Be Explained Later. end) game.ReplicatedStorage.BlahRemote.OnServerEvent:Connect(printBlah)
Now, If I were to make actionName either "Blah1" or "Blah2", Is there anyway to run the module function something like this?
local function printBlah(plr,actionName) blahModule.actionName(true) end)
Sorry for confusing text, and thankyou for any helps :D
yeah, you do both anonymous functions and regular functions like so:
module = require(game.Workspace.ModuleScript) module["testFunction"]() module["testAnonFunction"]()
local module = {} --anonymous function inside of a variable module.testAnonFunction = function() print("test anon function worked!") end --regular function inside of module table function module.testFunction() print("test function worked") end return module
test function worked
test anon function worked!