Add `plugin:PromptPickerAsync()` which lets plugins prompt the developer to pick an object

As a plugin developer, it is not possible to imitate the behavior of changing properties with an object type. It would be great if we had some sort of method to return an instance that the user picks. Yes, you can use the Selection service, but it isn’t as smooth (or obvious that you’re picking something), and it also can get confusing if you’re already selecting something.

The method I propose is called plugin:PromptSelectAsync(). It would trigger this selector mouse and wait until they picked something.

plugin:PromptPickerAsync(): (boolean, Instance?)

Prompts the developer to pick a single instance.
boolean: False if the user presses escape or loses focus.
Instance?: The object the user picked. nil if they clicked nothing, or if argument #1 is false.

It’s important to note that the selected instance can be nil for the boolean is true. The boolean represents if the “selection” should change. This replicates the behavior of how object values don’t change if you press escape or lose focus.

local current = nil

for i  = 1, 4 do
    local success, instance = plugin:PromptPickerAsync()

    if success then
        current = instance
    end

    warn("Current:", current)
end

If this was added, it would be another small step closer to allowing developers to make plugins that can do everything core plugins can do! Familiarity makes plugins feel more powerful and intuitive.

5 Likes