local mouse = game.Players.LocalPlayer:GetMouse()
local slider = script.Parent
local fill = script.Parent.fill
local trigger = script.Parent.trigger
local outputValue = script.Parent.outputValue
local outputLable = script.Parent.TextLabel
local maxValue = 0.9 or 90/100
local startingValue = 0.5 or 50/100
fill.Size = UDim2.fromScale(0, 1)
outputLable.Text = tostring(math.round(outputValue.Value*100))
local tween = game:GetService("TweenService")
local info = TweenInfo.new(.5, Enum.EasingStyle.Exponential)
function UpdateSlider()
local output = math.clamp(((Vector2.new(mouse.X,mouse.Y)-slider.AbsolutePosition)/slider.AbsoluteSize). X,0,1)
local outputClamped = startingValue + (output*(maxValue-startingValue))
if outputValue.Value ~= outputClamped then
tween:Create(fill, info, {Size = UDim2.fromScale(output, 1)}):Play()
end
outputValue.Value = outputClamped
outputLable.Text = tostring(math.round(outputValue.Value*100))
end
local sliderActive = false
function ActivateSlider()
sliderActive = true
while sliderActive do
UpdateSlider()
task.wait()
end
end
trigger.MouseButton1Down:Connect(ActivateSlider)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
sliderActive = false
end
end)
1 Like