How can I make volume bar thingy connected to two buttons?

Previously, I tried to make the script like this:

--MouseButton1Click script ^
if script.Parent.Volume.Volume.Size == (0, 0, 1, 0) then
script.Parent.Volume.Volume.Size = (0.1, 0, 1, 0)
script.Parent.Audio.Volume = 0.1
elseif script.Parent.Volume.Volume.Size == (0.1, 0, 1, 0) then
script.Parent.Volume.Volume.Size = (0.2, 0, 1, 0)
script.Parent.Audio.Volume = 0.2
elseif script.Parent.Volume.Volume.Size == (0.1, 0, 1, 0) then
script.Parent.Volume.Volume.Size = (0.2, 0, 1, 0)
script.Parent.Audio.Volume = 0.2
--This is only a prewiew of my script. Do not take it as the real script I am using.

I except to work like the volume bar, but it will cannot make it up 2 times, because of Propeties are still saying (0.1, 0, 1, 0) (Again, just a prewiew.).

Why don’t you just do this:

function Add()
    if script.Parent.Volume.Volume.Size.X.Scale < MaxScale and 
        script.Parent.Volume.Volume.Size.X.Scale >= MinScale then
        script.Parent.Volume.Volume.Size = UDim2.new(script.Parent.Volume.Size += 0.1, 0, 1, 0)
        script.Parent.Audio.Volume = script.Parent.Volume.Size.X
    end
end

function Subtract()
    if script.Parent.Volume.Volume.Size.X.Scale > MinScale and 
        script.Parent.Volume.Volume.Size.X.Scale <= MaxScale then
        script.Parent.Volume.Volume.Size = UDim2.new(script.Parent.Volume.Size -= 0.1, 0, 1, 0)
        script.Parent.Audio.Volume = script.Parent.Volume.Size.X
    end
end


Edit: Forgot to add the = in the if statement

1 Like

How can I make the MaxScale and MinScale?

Just set a variable somewhere at the top of the script.

local MaxScale = 0.2
local MinScale = 0
1 Like

Also, it works, but stops react when the size comes to 1

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.