Is the error: “attempting to index nil with name” by any chance?
In the create function ‘newModule’ isn’t defined, but may be accessed via ‘self’.
Look up metatables, as I think that might be helpful in this scenario.
This should run as an example of Oop, using your code, it seems a little overcomplicated although I’m not sure specifically what you want to do with it.
local module = {}
module.__index = module --added
--this will return a new module to the script that ran module.new(player)
function module.new(player)
local newmodule = {}
setmetatable(newmodule, module). --added
newmodule = {
["Move"] = {
["Baller"] = function()
--code stuff
print("works")
end
}
}
return newmodule
end
--this will run the code inside "Baller" IF "Baller" is passed as the movetype
function newmodule:create(movetype)
self.Move[movetype]()
end
return module
--in a script
local myModule = require(pathToModule) --define the path yourself
local myNewModule = myModule.new(player) --get the player yourself
myNewModule:create("Baller")
Is very close that im looking but what i want to is to
Table = {
["Firstability"] = {
["Attack1"] = function()
Print("worm")
End;
};
["Secondability"] = {
["Attack2"] = function()
Print("work")
End;
}
}
Function module:create(name, attack)
--name is the name that is inside of the "Table"
--attack is the function
End
Idk how to make a function to run a table inside a table and runs a function, how???
local module = {}
module.__index = module --added
--this will return a new module to the script that ran module.new(player)
function module.new(player)
local newmodule = {}
setmetatable(newmodule, module). --added
newmodule = {
["Standless"] = {
["Gun"] = function()
--code stuff
print("works")
end
};
["Baller"] = {
["c"] = function()
--code stuff
print("works2")
end
};
}
--this will run the code inside "Baller" IF "Baller" is passed as the movetype
function newmodule:create(name, attack)
self[name][attack]()
end
return newmodule
end
return module
Looks like you’re pretty new to programming or you’re using ChatGPT to create code for you.
I highly advise you to start reading the documentation from the very beginning.
For your issue, you can check out how module scripts work here: