Run when the slider's or status bar's value changes. Run when the value is set programmatically with Slider:SetValue() or StatusBar:SetValue(), as well as when the value is set by the user dragging the slider thumb.

Signature:

OnValueChanged(self, value)

Arguments:

  • self - Reference to the widget for which the script was run (frame)
  • value - New value of the slider or the status bar (number)

Examples:

-- Use a slider to move a frame across the center of the screen
local button = CreateFrame("Button", "TestButton", UIParent, "UIPanelButtonTemplate2")
local slider = CreateFrame("Slider", "TestSlider", UIParent, "OptionsSliderTemplate")
slider:SetPoint("CENTER", 0, -60)
slider:SetWidth(400)
slider:SetMinMaxValues(-200, 200)
slider:SetValueStep(1)
slider:SetScript("OnValueChanged", function(self, value)
      button:SetPoint("CENTER", value, 0)
end)
slider:SetValue(0)