Linking a module script with require()

I’m trying to make a global ban script.
I want to use module scripts but can’t work out how to get it to call upon the module script where I store all my bans.

Anyone know how to succesfully link it?

you simply write:

local myModuleScript = require(--[[localization of the module, for example:--]]script.ModuleScript)

So like

local BanList = require(12345 script.ModuleScript)

?

you would do:

local BanList = require(script.ModuleScript)

note that script.ModuleScript in require is changed depending on where your module script is localized.

1 Like

Ok , then how can I take the data from that module script and make it usable?
Like make it so I can take the bans and use them as data?

you declare the function in the module script and use it like this:

BanList.Ban(player)

If you need help understanding this, you should read the developer hub post first: ModuleScript | Documentation - Roblox Creator Hub

1 Like

The module script should return the banlist. You should write this in the module script:

return {
  "ROBLOX" -- Example Username
}

And in the script you should just require the module in a variable.

1 Like

Ok so I just put it in and got this:

Fetching bans failed because 502: API Services rejected request with error. HTTP 403 (Forbidden)

Know how to fix?

403 means you don’t have access to it. Requiring a module shouldn’t do this, from where did this error get thrown?

1 Like

@ThePoisonFish
Never mind , was probably just an error.
It seems to be working now!