FunctionsPlus - Expanded functions

Get the model

What is FunctionsPlus?

FunctionsPlus is a free, open source module containing extra functions so you don’t have to type extra lines of code.

Current functions:

Add a function

Want to add a function? Fill out this form.

Enjoying FunctionsPlus? Consider supporting!

3 Likes

For the table functions, what is the difference from using

table.find(someRandomTable, index) -- for table.findn

and

someRandomTable[int]  -- for table.findt

Personally I think it would be easier to use those rather than require a custom function module to do so

1 Like

table.findn is really just supposed to be an alias to table.find if you want to use the module’s function. table.findt is mainly for the same reason as above, plus it can be used by someone who does not fully understand table.find.

1 Like

WaitForChildOfClass incorporates a repeat loop which probably isn’t a good idea, especially because it’ll end up yielding even if the item already exists. Would recommend an event-based solution that uses ChildAdded and checks the class of the given child. This is essentially how WaitForChild is implemented internally as well. If you want a loop, then at least use an event’s wait method.

local function WaitForChildOfClass(parent, class)
    local object = parent:FindFirstChildOfClass(class)
    -- Executes body only if condition evaluates false
    while (parent) and (not object) do
        object = parent:FindFirstChildOfClass(class)
        parent.ChildAdded:Wait()
    end
    return object
end

A little crude though since it just calls FindFirstChildOfClass right after the first one potentially returns nil, though. You could reverse the conditions if it causes no trouble.

3 Likes

Thanks for the feedback and explanation on a better WaitForChildOfClass, I will replace the current function with the new function. : )

1 Like