-
What do you want to achieve? Keep it simple and clear!
I want to make a round script.
-
What is the issue? Include screenshots / videos if possible!
This is my code (it’s in a module script):
It’s erroring saying this.
and this
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking around but found nothing similar to this problem.
Could someone tell me why it’s erroring like this? I want to run my code in the module in a main script but this error appears in the module script.
2 Likes
Someone correct me if I’m wrong;
I’m pretty sure this can’t be in a table.
You can’t put variables and the like in a table, you need to put it outside of the local module = {}
table or make it as a module function
Since a module is just basically a table, you don’t need to put local in front of it. It is weird that you’re using a module for this though, you can put the script inside the module in a normal script and it would work. This isn’t how modules work.
If you wanna use modules, I’d recommend you learn the basics of it. But to be honest, it would be easier to move this to a normal script, since basically the code is correct.
Are you planning on using the function for the round system in multiple scripts firstly? If not, just use a regular script like how @HammyLammyYT stated
I already know the basics of module scripts and I’ve done many things like this before. I want to use module scripts because I don’t want my main script to be very messy and I want to locate bugs and errors quicker.
That does make sense, but to be honest I’d find it simpler if you had a function in your main script which is named ‘startIntermission’ or something. In my opinion, that still is clean code.
local function startIntermission()
-- code
end
If you wanna use this module, you have to put a function to the module.
local module = {}
function module.startIntermission()
-- code
end
return module
With – code just being the code you currently have inside the module.
How would I run a module script function from the main script?
local roundModule = require(path.to.module)
roundModule.startIntermission()
1 Like
You just need to require the module and then index the function
local intermissionModule = require(path.to.module)
intermissionModule.startIntermission() -- this is how you run a function inside a module
1 Like