Toggles

To create a toggle, use this.

local Toggle = Tabs.Main:AddToggle("MyToggle", 
{
    Title = "Toggle", 
    Description = "Toggle description",
    Default = false,
    Callback = function(state)
	if state then
	    print("Toggle On")
	else
	    print("Toggle Off")
        end
    end 
})

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

MyToggle (name of toggle) 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)

Toggle.Value

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

Options.MyToggle.Value

Functions

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

Toggle:OnChanged(function()
    print("Toggle changed:", Options.MyToggle.Value)
end)

To set the value of the toggle, use this.

Toggle:SetValue(false)

Last updated