UI Drag Detectors Question

image
This is my game volume setting. I want it to be able to slide and scale like a sliding settings bar, but UI Drag detector only changes the position. Is there a way to make UI Drag Detector change the size of the button? Any help is appreciated.

something like this

dragDetector.DragChanged:Connect(function()
	local dragX = dragDetector.Position.X.Offset
	local barWidth = volumeBar.AbsoluteSize.X

	-- Clamp drag position between 0 and barWidth
	local clampedX = math.clamp(dragX, 0, barWidth)

	-- Set new size of the fill bar
	fill.Size = UDim2.new(0, clampedX, 1, 0)

	-- Optional: Calculate volume percent
	local volumePercent = clampedX / barWidth
	print("Volume:", math.floor(volumePercent * 100) .. "%")
end)
1 Like

relativestyle is what you need probably
image

1 Like

you could make the background frame clip descendants and then the dragdetector moving the green frame is fine

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.