Dropdowns

Changing Dropdown Values

To change what a dropdown has, use this.

Dropdown:SetValues({"one", "two", "three"})

To create a dropdown, use this.

local Dropdown = Tabs.Main:AddDropdown("Dropdown", {
    Title = "Dropdown",
    Description = "Dropdown description",
    Values = {"one", "two", "three"},
    Multi = false,
    Default = 1,
    Callback = function(Value)
        print("Dropdown was changed:", Value)
    end
})

The Value returns the selected value.

Change local Dropdown to a different variable name every time. It can be anything.

Dropdown (name of dropdown) is saved in the Options variable.

You can try to remove it, but I've never tried to.

You can get the value anywhere simply by using this: (Put your variable name)

Dropdown.Value

Or, whatever you put as the name of the toggle.

Options.Dropdown.Value

You can check when the dropdown is changed, but Callback does the same thing.

Dropdown:OnChanged(function(Value)
    print("Dropdown changed:", Value)
end)

To set the value of a dropdown, use this.

Dropdown:SetValue("three")

Multiple Dropdowns

To create a dropdown with multiple values, use this.

local MultiDropdown = Tabs.Main:AddDropdown("MultiDropdown", {
   Title = "Dropdown",
   Description = "You can select multiple values.",
   Values = {"one", "two", "three"},
   Multi = true,
   Default = {"seven", "twelve"},
})

Change local MultiDropdown to a different variable name every time. It can be anything.

MultiDropdown (name of dropdown) is saved in the Options variable.

You can try to remove it, but I've never tried to.

Information

Multi Dropdowns are super annoying. It returns the Value of every Value and if it's true or not.

An example is shown below.

return {
    ["one"] = true
    ["two"] = true
    ["three"] = false
}

To get the value of something, simply use

MultiDropdown.Value["one"]

Or, whatever you put as the name of the toggle.

Options.MultiDropdown.Value["one"]

This will return "true" if it's true.

Functions

You can check when the multi dropdown is changed, but Callback does the same thing.

MultiDropdown:OnChanged(function(Value)
    local Values = {}
    for Value, State in next, Value do
        table.insert(Values, Value)
    end
    print("Mutlidropdown changed:", table.concat(Values, ", "))
end)

To set the value of a multi dropdown, use this.

MultiDropdown:SetValue({
   three = true,
   five = true,
   seven = false
})

Last updated