A library of short, useful functions to aid in ROBLOX development. Get a built version from ROBLOX here.
A list of support functions provided by the module, by category:
Returns a table of keys where Needle is found in table Haystack.
Returns one key where Needle is found in table Haystack, or nil if not found.
Returns a boolean determining whether Needle is found in table Haystack.
Returns whether the contents of tables A and B match each other identically, key-by-key.
Returns a new table whose contents are identical to Table. Note: Metatables are not copied over.
Returns the common item in table Items, or nil if the contents of Items vary.
Inserts all values from SourceTable into DestinationTable, and returns DestinationTable. Note: Only values are inserted into DestinationTable; keys are not preserved.
Clears out every value in Table, and returns the same now-empty Table.
Returns a new table containing all values found in Table.
Returns a new table containing all keys found in Table.
Returns the total number of keys in table Table.
Returns a new table containing the values of Table from index Start, to index End, in order.
Returns a new table with keys and values from table Table swapped.
Example:
local Table = { 'Hi', 'Hello' }
local FlippedTable = Support.FlipTable(Table)
print(Table[1]) --> Hi
print(FlippedTable.Hi) --> 1Returns a table containing the values at index MemberName of each indexable item in table List.
Returns Number rounded to the given number of decimal Places.
Returns Number clamped to the given Minimum and Maximum values.
Example:
print(Support.Clamp(5, 0, 3)) --> 3
print(Support.Clamp(-0.5, 0, 1)) --> 0Returns a table containing all the descendants of instance Parent.
Returns the total number of descendants within instance Parent.
Returns a new table containing clones of the instances in table Parts, with matching keys.
Returns a child within instance Parent of class ClassName, or nil if not found.
If Inherit is true, class inheritance is taken into account. By default, class names must be identical to match.
Returns a table of children within instance Parent of class ClassName.
If Inherit is true, class inheritance is taken into account. By default, class names must be identical to match.
Returns the common value of property Property across instances in table Items, or nil if the items' properties' vary.
Returns a table containing the CFrames of corners of part Part. Note: Shape is always assumed to be a rectangular prism.
Returns the parts of string String after splitting it by pattern string Delimiter.
Returns String without leading or trailing spaces.
Returns a function, which calls function Function with arguments ....
Example:
Support.Call(print, 'Hi')() --> HiReturns a function, which when called, calls each function in ... with the passed arguments. Each function listed in ... receives the returned values of the previous function.
Example:
Support.ChainCall(string.upper, print)('Hello!') --> HELLO!Calls TaskFunction every Interval seconds asynchronously. Returns a controller to stop the task, or check if it's running (Task:Stop(), or boolean Task.Running).
Example:
function PrintHi()
print 'Hi'
end
local Task = Support.ScheduleRecurringTask(PrintHi, 0.5) --> Begins printing 'Hi' every 0.5 seconds
wait(5)
Task:Stop() --> Stops printing 'Hi' every 0.5 seconds after 5 secondsInjects variables to common services into the environment in which the function was called.
| Service Name | Variable Name | Different |
|---|---|---|
| Workspace | Workspace | |
| Players | Players | |
| MarketplaceService | MarketplaceService | |
| ContentProvider | ContentProvider | |
| SoundService | SoundService | |
| UserInputService | UserInputService | |
| Selection | SelectionService | X |
| CoreGui | CoreGui | |
| HttpService | HttpService | |
| ChangeHistoryService | ChangeHistoryService | |
| ReplicatedStorage | ReplicatedStorage | |
| GroupService | GroupService | |
| ServerScriptService | ServerScriptService | |
| StarterGui | StarterGui | |
| RunService | RunService |
Example:
Support.ImportServices()
print(MarketplaceService:GetProductInfo(516682015).Creator.Name) --> F3X
print(GroupService:GetGroupInfoAsync(831895).Id) --> 831895Returns a connection to the requested user input event (UserInputService.InputInputState), and calls function Callback(InputObject) when the UserInputType matches InputType. Ignores game-processed input events, unless CatchAll is true. Also ignores keyboard input if a TextBox is currently in focus.
Example:
Support.AddUserInputListener('Began', 'Keyboard', false, function (Input)
print(Input.KeyCode) --> Enum.KeyCode.A
end)Returns a connection to the requested user input event in GUI instance Gui, and calls function Callback(InputObject) when the UserInputType matches InputType. Ignores game-processed input events, unless CatchAll is true.