#UI Drag Detector issue

1 messages · Page 1 of 1 (latest)

gritty moss
#

I tried making a slider for volume, but the problem is that the handle goes below 0 and above 100 depending on where I hold it. When I hold it on the left side, I can go below 0, when on the right, I can go above 100. It has 100 "positions(?)" so when I can go to -3 it will go to 97 max (hope thats understandable)
also here's the script that I used for that:

-- Hierarchy is SliderContainer ⟩ Handle ⟩ UIDragDetector ⟩ (this script)
local sliderContainer = script.Parent.Frame.line
local handle = sliderContainer:FindFirstChild("Frame")
local uiDragDetector = handle:FindFirstChildWhichIsA("UIDragDetector")
local volume = sliderContainer.Parent.TextLabel

uiDragDetector.ResponseStyle = Enum.UIDragDetectorResponseStyle.Scale  -- Set dragging by scale
uiDragDetector.DragStyle = Enum.UIDragDetectorDragStyle.TranslateLine  -- Restricts dragging to line


-- Initially set container transparency to X scale value of handle
volume.Text = tostring(math.ceil(handle.Position.X.Scale * 100))

-- Expand handle border to indicate grab start
uiDragDetector.DragStart:Connect(function(inputPosition)
    handle:FindFirstChildWhichIsA("UIStroke").Thickness = 6
end)

-- Change transparency by how much it dragged in scale
uiDragDetector.DragContinue:Connect(function(inputPosition)
    volume.Text = tostring(math.ceil(handle.Position.X.Scale * 100))
end)

-- Revert handle border to indicate grab end
uiDragDetector.DragEnd:Connect(function(inputPosition)
    handle:FindFirstChildWhichIsA("UIStroke").Thickness = 4
end)
somber moon
#

You want it to only go from 0 to 100?

gritty moss
#

yea

north trellis
#

clamp it

somber moon
#

This is all AI code btw

north trellis
#

bc the detector

somber moon
north trellis
gritty moss
somber moon
#

oh well then

north trellis
#

clamp it into range

#

every drag update

#

ask gpt u got this