Retrieving objects from the pool

You can retrieve an object from the pool with the :Get() method

local QueuedInstance = ObjectPool:Get()
-- this will return the first unloaded (unless LiveReusing is true) within the table

Alternatively, you can get AND load the object into the game using :LoadItem()

local QueuedInstance = ObjectPool:LoadItem(Parent)
-- :LoadItem() functions similarly to :Get(), except it instantly loads the QueuedInstance and accepts 'Parent' as a parameter, Parent is an instance that the QueuedInstance will be parented to

Bulk retrieval

You can get a table containing all the QueuedInstances using :GetAll()

local ListOfInstances = ObjectPool:GetAll()
-- returns a table with all the instances

You can also immediately load all the QueuedInstances using :LoadAll()

local ListOfInstances = ObjectPool:LoadAll()
-- returns a table with all the instances and loads them all if they are unloaded
-- loaded instances are ignored

Last updated