So I’m making a system that spawns trees and rocks in the world, each of which can be interacted with, with a proximityPrompt.
For trigger detection I’m putting the prompts in an array and call them with a for-loop.
Would the most performant way be to put the prompts of both rocks and trees in a single table, or separate them so that the code has to run through less objects for each type on activation?
(Or is there an alternative way to run through multiple proximityPrompts that I’m not aware of?)
If you were to do it your original way, then I would suggest the latter, but I think most people would suggest using CollectionService. This allows you to essentially tag different groups of instances and manage all tagged instances with a single script.
Useful info:
“Tags can be added or removed through this class’ methods such as AddTag() or RemoveTag(). They can also be managed directly in Studio through the Tags section of an instance’s properties, or through the built‑in Tag Editor tool.”