How would I go about making a slider

Hello there, I’m trying to aim to make a slider where lets say every second it moves about an inch until it reaches its desired spot. I would like to try and use Tweenservice for this but if it is not possible then I could resort to another method.

My exact question is how would I create a slider that moves about an inch until it gets to its desired spot but all in 10 seconds?

Any help is appreciated, thanks!

1 Like

By that you mean like a progress bar? You can use tweenservice for that:

local tweenservice = game:GetService("TweenService")
local fill = script.Parent.fill

fill:TweenSize(UDim2.new(1,0,1,0),nil,nil,10)

If you mean literal slider then you can use TweenPosition instead.

No, not a progress bar. I mean a line that every second moves an inch.

Use tweenservice.

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(10, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local Tween = TS:Create(PartToTween, TI, {PROPERTY TO TWEEN = VALUE})
Tween:Play() -- to play the tween.

Or use :TweenPosition() for UI.

GUI_HERE:TweenPosition(UDim2.new(desiredlocation), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 10, true)
1 Like

Okay, thanks. I will try this in a bit.

Do you mean a GUI, or a Part?
With a Part you could use a PrismaticConstraint and calculate the Velocity based on the distance needed to travel/10 seconds.
If you want to tween the Part then go with @AstraI_YT’s post.

2 Likes

I’m using your first example for tweening a frame, or should I use the second?

It doesn’t matter, the second is generally more widely-used for UI Frames being tweened.

:TweenPosition() also doesn’t require you to call TweenInfo or TweenService.

1 Like