Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Making Custom Libraries?

Asked by 9 years ago

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

Log in to vote
0
Answered by
Nymint 85
9 years ago

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

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. aquathorn321 858 — 9y
0
I tried it again. It returns a nil value. aquathorn321 858 — 9y
0
The problem with using a method like this is I can't run the script in the studio without launching a test. aquathorn321 858 — 9y
0
Hold on just a moment... Nymint 85 — 9y
View all comments (3 more)
0
To use in studio add the "Script or LocalScript" section to the COMMANDBAR. Lacryma 548 — 9y
0
Well yeah, but I can't reference it easily. It's not efficient that way. aquathorn321 858 — 9y
0
dont use . use : on line 2 in script/localspript and on line 3 in ModuleScript RM0d 305 — 9y
Ad

Answer this question