CollectionService Module

CollectionService Module


This module is designed to make working with CollectionService easier and more straightforward.
Previously, you may have been tediously creating new, long scripts for each new tag you want to program.
This module makes that process as quick as possible, by using the new function as shown below:

local Collection = require(...) -- Path to the module


Collection.new('TestTag', function(object: Instance) -> {Instance | RBXScriptSignal}?
    print(object, 'given TestTag')


    local highlight = Instance.new('Highlight')
    highlight.Parent = object
    

    local connection = object.Touched:Connect(function(hit)
        print(object, 'was touched')
    end)


    return {highlight, connection}
end)

Whenever an instance is given the tag, the tagAddedFunction will be run on it.
The tagAddedFunction can return a table of things you want to be cleaned up once the tag is removed, such as Instances or Connections.
You can also return nil if nothing is needed to be deleted after the tag is gone.


If you have any suggestions / requests / bug fixes / etc. feel free to mention them.


GET:

1 Like