So im trying to obviously trying to make a slider that plays audio and thankfully my script works! (the script is on the main image) What it does is it simply swipes left to right if you hold it.
However, i want a way to make the audio become loud when its to the right, and silent when its too the left, and default setting to the right
Simply just update me on what i could add. script is here: local handle = script.Parent local slider = handle.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse() local dragging = false
`handle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
while dragging do
local percentage = math.round(Snap(math.clamp((mouse.X - slider.AbsolutePosition.X)/slider.AbsoluteSize.X, 0, 0.9), .02)*100)/100
handle.Position = UDim2.new(percentage, 0, handle.Position.Y.Scale, 0)
task.wait(.01)
local value = ((-.5 * (1 - percentage)) + (1 * percentage))
print(value)
end
end
end)
handle.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
function Snap(value, snapValue)
return value - (value % snapValue)
end
`
And lastly for the percentage, i want it to show me the percentage when the button is in a specific place, and if i click the percentage Textbox, it allows me to type in a percentage of volume and also once click and dragged makes the button move at the place where the percentage specified. A LOCALSCRIPT OR AND UPDATED VERSION OF MINE WOULD HELP ALOT, THAAAANKS!