Module for making volume knobs

UI Volume Knob


Preview:


Example:

Knob: ImageButton
Value: TextLabel

LocalScript
--// Modules
local Module = require(game.ReplicatedStorage:WaitForChild("Knob"))

--// Variables
local gui = script.Parent
local value_ui = gui:WaitForChild("Value")
local knob_ui = gui:WaitForChild("Knob")
local knob_class = Module.new(knob_ui)

--// Changing knob properties
knob_class.Range.Min = -100
knob_class.Range.Max = 100
knob_class.Value = 25
knob_class:Visualize() -- update

--// Functions
local function UpdateText(value, alpha)
	value_ui.Text = knob_class.Value
end

--// Updating UI Value
knob_class.Signal:Connect(UpdateText)
UpdateText(knob_class.Value, knob_class:GetAlpha())

Download


Roblox Library: https://www.roblox.com/library/14339500778/Knob-Module

API


Functions

Module.new(knob_ui: ImageButton): Knob

Properties

Knob.Signal: Signal → Fires when the Adjust method gets called

Signal

Signal API :point_down:

Signal:Connect(function → (value: number, alpha: number)): RBXScriptConnection


Knob.TweenInfo: TweenInfo

Knob.KnobRotation: table → {Min: number, Max: number}

Knob.Range: table → {Min: number, Max: number}

Knob.DragSensitivty: number

Knob.DragMethod: string → “X” or “Y”

Knob.Value: number

Methods

Knob:GetAlpha(): number

Knob:Visualize(): nil → updates the gui knob (use this after changing properties manually)

Knob:Adjust(value: number) → changes value and updates gui knob

11 Likes