Hello, I’m working on a game and I came across a issue that I’m having with a module script and I’m unsure why its happening.
So I have a function inside my module script but for some reason when I try to access it through the other script, it doesn’t find the function and only finds the variables.
I’ve tried doing research for why this could be happening but nothing has helped so far.
Here’s a screenshot showing what the script is finding in the module script:
Here’s a screenshot of the function in the module.
When I try to run this it says: attempt to call a nil value
I assume this is because its not finding the function so its just returning nil.
I’m unsure why this is occurring, I have other games that I’ve done the same thing on and they work fine so I don’t understand why this one isn’t. If anyone knows why this is happening please let me know, I’ll appreciate it!
Because you are not adding the function to the Table, you would need to do put the Table. and then the operator to use, which can be a Colon, or a Period, these are primarly used for Object Oriented Programming which for this, I wont go over this as it is not exactly relevant.
You are essentially creating the Function within the ModuleScript,But you are returning a table which does not contain the information as it is not referenced inside it, which would be something like this:
func = function() -- a function by itself, not indexed inside the table
end
tab.func = function() -- a function indexed inside the table
end
and since the function is indexed within the table, it would be returned along with the rest of the data that it contains.
Think about it like this, you have a table, and you are trying to export the data to another location, anything that is not inside this table will not be exported unless added.