Because you’re printing a function, you’re calling the function inside another function, making the script thinks you’re trying to print out a function.
You technically already have the function “name”. When you do cmdFunctions.testprint(), “testprint” is the name
local name = "testprint"
local func = cmdFunctions[name]
print("Function name:", name)
func()
You can use a for loop and iterate the cmdFunctions dictionary which would give you every key (func name) and value (func) (if you’re trying to display all commands for example)
local cmdFunctions = {
testprint = function()
print("testprint function called")
end,
}
for name, func in pairs(cmdFunctions) do
print("Function name:", name) -- > Function name: testprint
func() -- > testprint function called
end