Volume adjuster is overlapping

So i want to make a volume adjuster, that can adjust the volume by using a dragable frame.

My problem is that my frame is overlapping
image

How to prevent this?

Script is here

local GetMouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService(“UserInputService”)
local Tracker = VolumeTracker.Tracker
local Trigger = VolumeTracker.Tracker.DragButton
local MouseButton = Enum.UserInputType.MouseButton1
Trigger.InputBegan:Connect(function(input)
if input.UserInputType == MouseButton then
print(“Fired”)
local LastPos = Vector2.new(GetMouse.X)
while UIS:IsMouseButtonPressed(MouseButton) do
local delta = Vector2.new(GetMouse.X) - LastPos
Tracker.Size = Tracker.Size + UDim2.new(0,delta.X,0)
LastPos = Vector2.new(GetMouse.X)
wait()
end
end
end)

May you show us a script you are using?

local GetMouse = game.Players.LocalPlayer:GetMouse()
local UIS = game:GetService(“UserInputService”)
local Tracker = VolumeTracker.Tracker
local Trigger = VolumeTracker.Tracker.DragButton
local MouseButton = Enum.UserInputType.MouseButton1
Trigger.InputBegan:Connect(function(input)
if input.UserInputType == MouseButton then
print(“Fired”)
local LastPos = Vector2.new(GetMouse.X)
while UIS:IsMouseButtonPressed(MouseButton) do
local delta = Vector2.new(GetMouse.X) - LastPos
Tracker.Size = Tracker.Size + UDim2.new(0,delta.X,0)
LastPos = Vector2.new(GetMouse.X)
wait()
end
end
end)

1 Like

I’ve tried if hitting a specific pos then return end but that didn’t work

1 Like

You should add another condition in while loop to stop once player drags the size to max.
For example:

while UIS:IsMouseButtonPressed(MouseButton) and DragBar.Size.X <= 100 do
2 Likes

Didn’t quite work i have tried this while UIS:IsMouseButtonPressed(MouseButton) and Tracker.Size.X <= 164 do

Where are you defining ‘Tracker’ variable also you will have to define if are you scaling ‘offest’ on X-axis or just ‘Scale’ in general. Try to use:

while UIS:IsMouseButtonPressed(MouseButton) and Tracker.Size.X.Scale <= 164
1 Like

Yep that works fine, but when the dragbar hits the specific size it brakes the script
while UIS:IsMouseButtonPressed(MouseButton) and Tracker.Size.X.Offset <= 164 and Tracker.Size.X.Offset >= 0 do

I think its because the player can’t come out of the size and it just keep being there if that makes sense

You can esaily fix that by checking with an if statment if size is max then change the size for 1 px.
This is taken from your source:

if input.UserInputType == MouseButton then --find this where you are defining it in source code
  print("Fired")
  if Tracker.Size.X.Scale > 163 then
       Tracker.Size.X.Scale = 163
   end
end

Yeah i was just trying it out :smiley:

1 Like

Nah its not quite working

Trigger.InputBegan:Connect(function(input)
if input.UserInputType == MouseButton then
print(“Fired”)
local LastPos = Vector2.new(GetMouse.X)
while UIS:IsMouseButtonPressed(MouseButton) and Tracker.Size.X.Offset <= 164 and Tracker.Size.X.Offset >= 0 do
wait()
if Tracker.Size.X.Offset > 164 then
Tracker.Size.X.Offset = 164
end
local Delta = Vector2.new(GetMouse.X) - LastPos
Tracker.Size = Tracker.Size + UDim2.new(0,Delta.X,0)
LastPos = Vector2.new(GetMouse.X)
end
end
end)

Try this source:

Trigger.InputBegan:Connect(function(input)
 if input.UserInputType == MouseButton then
  print(“Fired”)
   if Tracker.Size.X.Offset > 163 then
    Tracker.Size.X.Offset = 163
  end
local LastPos = Vector2.new(GetMouse.X)
while UIS:IsMouseButtonPressed(MouseButton) and Tracker.Size.X.Offset <= 164 and Tracker.Size.X.Offset >= 0 do
   wait()
   local Delta = Vector2.new(GetMouse.X) - LastPos
   Tracker.Size = Tracker.Size + UDim2.new(0,Delta.X,0)
   LastPos = Vector2.new(GetMouse.X)
   end
  end
end)