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
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)
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)
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
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)
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)