Hey there! I made some new functions that could help someone save their precious time so they don’t have to type a lot of stuff!
I will explain how this works in case you’re wondering. If you think this should go in another place, please tell me so I can move it to that category.
MainModule.lua (1.5 KB)
Updated Version here:
Get it here or More Functions - Roblox
First insert a script, and require it.
local module = require(5323642034)
Now we can start using the functions!
Function 1
module:GetChildrenOfClass(object, className)
This function returns an array of children which has that class.
Example:
for i, v in pairs (module:GetChildrenOfClass(workspace, 'BasePart')) do
print(v.Name)
end
Only children of workspace that has the class BasePart will be printed. Stuff like Folders or Terrain don’t have this class so their name won’t be printed.
Function 2
module:GetChildrenOfProperty(object, propertyName)
This function returns an array of children which has that property.
Example:
for i, v in pairs (module:GetChildrenOfProperty(workspace, 'WaterWaveSize')) do
print(v.Name)
end
Only Terrain will be printed because only Terrain has this property. If you put Anchored then only objects with the property Anchored will be printed.
Function 3
module:GetChildrenWhichHasAChildrenOfClass(object, className)
This function returns an array of children which has a children that has that class. Kind of confusing but you’ll get what I mean.
Example:
for i, v in pairs (module:GetChildrenWhichHasAChildrenOfClass(workspace, 'ClickDetector')) do
print(v.Name)
end
Only objects with a ClickDetector will be printed. If a ClickDetector isn’t in any children of workspace, its Name won’t be printed.
Function 4
module:GetChildrenWhichHasAChildrenOfProperty(object, propertyName)
This function returns an array of children which has a children that has that property.
Example:
for i, v in pairs (module:GetChildrenWhichHasAChildrenOfProperty(workspace, 'CursorIcon')) do
print(v.Name)
end
Only objects with a ClickDetector will be printed because only ClickDetectors have this property. If a ClickDetector isn’t in any children of workspace, its Name won’t be printed.
Function 5
module:GetAncestors(object)
This function returns an array of ancestors of an object.
Example:
for i, v in pairs (module:GetAncestors(script)) do
print(v.Name)
end
If this script was in folder in ServerScriptService, it would print Folder and ServerScriptService. It won’t print game.
Function 6
module:GetAncestorsOfClass(object, className)
This function returns an array ancestors that has that class.
Example:
for i, v in pairs (module:GetAncestorsOfClass(script, 'Folder')) do
print(v.Name)
end
If this script was in folder in ServerScriptService, it would only print Folder because ServerScriptService isn’t a folder. It won’t print game no matter what.
Function 7
module:GetAncestorsOfProperty(object, propertyName)
This function returns an array of ancestors that has that property.
Example:
for i, v in pairs (module:GetAncestorsOfProperty(script, 'LoadStringEnabled')) do
print(v.Name)
end
If this script was in folder in ServerScriptService, it would only print ServerScriptService because only it has this property. It won’t print game no matter what.
Function 8
module:GetSiblings(object)
This function returns an array of siblings.
Example:
for i, v in pairs (module:GetSiblings(workspace.Folder)) do
print(v.Name)
end
All siblings of Folder will be printed, even Terrain and Camera.
Function 9
module:GetSiblingsOfClass(object, className)
This function returns an array of siblings that has that class.
Example:
for i, v in pairs (module:GetSiblingsOfClass(workspace.Folder, 'Folder')) do
print(v.Name)
end
If there was only one folder in workspace, nothing will be printed. The object itself won’t be printed because we’re finding the siblings not the object.
Function 10
module.tableCombine(table1, table2)
This function combines 2 tables.
Example:
for i, v in pairs (module.tableCombine(workspace:GetChildren(), module:GetAncestors(script))) do
print(v.Name)
end
They would be combined into a table, and it works for :GetChildren()
, normal tables and even module functions!
Function 11
module.dictionaryIndex(dictionary, value)
This function finds the value in the dictionary, then returns the index or key.
Example:
local table = {
['Cheese'] = 'Stuff from cows',
['Cows'] = 'Animals'
}
for i, v in pairs (module.dictionaryIndex(table, 'Animals')) do
print(v.Name)
end
Cows would be printed as it is the index of Animals.
Got any questions or recommendations?
If you think I should add more stuff, feel free to tell me so I can add them! I know some of the functions have really long names so suggest some so it’s easier to type out the functions! If you think this isn’t explained clearly please also tell me. You can download the MainModule to check it out!