What is require and how do I use it?

I have made a script and want to place it into a game without leaking it’s true code. I have seen this be done with many things, like admin loaders where ‘require’ is used. So like this

require (1234567890)

How would I use require to keep a script secret? My script is basically an Admin Script.

9 Likes

You would use require by making a ModuleScript that’s named and publishing it to the ROBLOX website.
You would then require the ROBLOX ID of the module.

5 Likes

This was functionality called Private Modules and was [removed in February].(Removing Support for Third Party Closed Source Modules)

Require is generally used to load ModuleScripts. Modules can be published as public models and then required into any game. You can learn more about this on the ModuleScript page I have linked.

17 Likes

Sorry I’m a bit late by 2 years, but I thought this would be helpful for anything coming back. You can also get module, and use it for cars without needing to load, and you normally need to call it to get an internal module.
image

local Module = require(game.ReplicatedStorage.MyModule)
Module.MyFunction(MyParameters)

Or, more simple.

require(game.ReplicatedStorage.MyModule).MyFunction(MyParameters)

You can also use it like this.

require(game.ReplicatedStorage.MyModule).MyFunction
if true then print("Returned true!") end

As long as you have return true somewhere in your function.
Again, sorry for the late post, thought it would be helpful for anyone looking for this in old topics.

1 Like