to make it clearer, I have a modulescript that returns a function when it's required. the main script (which is requiring the modulescript ) is supposed to run the function, but its running the function as if it were the modulescript running it. how would I fix that? sorry if this is confusing.
COMMUNITY QUESTION
how do I run a function from a module script as if it were being run from the same script?
1 answer
when creating a function in a module script, you have to put... i don't know how to explain it but look
old module
local module = {}
function jump() print "Jumping" end return module
old server script
m = require (workspace.module) m:jump
output attempt to call method 'jump' (a nil value)
new module
local module = {}
function module:jump()-- I've added the value module and put a ":" and then the function print "Jumping" end return module
server script
m = require (workspace.module) m:jump-- code will now work
output Jumping
This discussion is preserved as it was. New answers, comments, and votes are closed.
