#Need help with ui sliders

1 messages · Page 1 of 1 (latest)

raw horizon
#

Im making a slider with the uidragdetector. The slider will go from 0 - 100 depending on where the position of the handle is. However in my case it goes to 0 - 88 cause the anchor point on the left bottom corner never reaches the end. Any solutions on how to fix this without changing the design?

Changing the ancor point to the middle makes it so the handle is halfway outside the frame on both sides, and instead of 0 - 88, it goes from 6 - 94

low salmon
#

yo?

split summit
#

dude is helping everyone

low salmon
#

Lol im just bored 😭

split summit
#

thats fair

low salmon
#

@raw horizon

#

you still need help?

raw horizon
#

yes

stone prairieBOT
#

studio** You are now Level 3! **studio

low salmon
#

Alright

#

so the anchor point is in the bottom left of the handle
The handle can’t fully reach the edges without part of it going outside the track, since its width takes up space.

sooooo Instead of directly mapping position to 0–100, calculate the effective travel range

#

do u need me to explain?

raw horizon
#

yes please

#

that would very helpful

low salmon
#

For sure

#

so ur slider handle doesn't go from 0 to 100 because its not allowed to reach the exact edges of the track due to its size and anchor point

and so if the handle is anchored on the left, it starts at 0 and maxes out at trackWidth - handleWidth, not trackWidth.
"local travelRange = trackWidth - handleWidth"

to be clearer say if the track is 100 pixels wide, and the handle is 12 pixels wide then travel range = 100 - 12 = 88 soo ur value should go from 0 to 88 across the full drag but we want a nice clean 0–100 value

so then you wanna say this insted: "local sliderValue = (handlePos / travelRange) * 100"
if the handle is at position 0, you get 0
if it’s at 44 you get 50
if it’s at 88, you get 100

#

now looking at your code this is your issue
local currentScale = math.round(dragBar.Position.X.Scale * 100)

raw horizon
#

@low salmonhow exactly do I get the travelRange?

low salmon
#

you need to account for the width of both the track and the handle

#

Get the width of the track Get the width of the handle Calculate the travel range

remember: local travelRange = trackWidth - handleWidth

raw horizon
#

@low salmonwhat did I do wrong?

#

it stops at .77

#

I got the travel range in pixels which was 115

#

Nvm!

#

I got it

low salmon
#

Alright 😭

#

im helping a lot of ppl in diff servers sorry bro

raw horizon
#

had to change it to offset instead of scale in the uidragdetector properties

low salmon
#

but hopefully i helped enough

#

OOo Nice work

raw horizon
#

you helped me a lot thank you so much