Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making Custom Libraries?

I want to make custom global functions I can use in studio, and so far the best way to do this I've found so far is if I create my own library. However, I do not know how, so could someone elaborate on how libraries function and how I could create and implement my own?

1 answer

This is where ModuleScripts come in, ModuleScript will work for you as a Library of values, userdata, tables, and functions anywhere anytime you want.

First you Insert a ModuleScript, add it anywhere you want, I usually add mine in ReplicatedStorage. Name it, then in it, you gotta make a table, then return the table, and do your functions in it or by using function TableName.FunctionName() end.

ModuleScript

local Lib={}

function Lib.Print(Text) print(Text) end

return Lib

Script or LocalScript

local Lib=require(YourModuleScriptScopeLocation)
Lib.Print("Sup")

Sup

7 comments

0

I've tried that before in studio, but it didn't seem to work well. The script wouldn't return a function and it would result in an error.

0

I tried it again. It returns a nil value.

0

The problem with using a method like this is I can't run the script in the studio without launching a test.

0

Hold on just a moment...

0

To use in studio add the "Script or LocalScript" section to the COMMANDBAR.

0

Well yeah, but I can't reference it easily. It's not efficient that way.

0

dont use . use : on line 2 in script/localspript and on line 3 in ModuleScript

This discussion is preserved as it was. New answers, comments, and votes are closed.