Hey!
If you don’t understand what I mean by UI-dragger, here an explanation:
Many games use those draggers for their settings. For example you can drag a line to the right to higher the volume, and to the left to lower it.
I’m wondering if there is an easier solution to make a dragger for an UI than using Mouse’s Button1Down, Button1Up, check where the mouse now is, or even make a Heartbeat so it follows along the mouse.
Could you link me the video please? I can’t find any videos that show how to make a dragger for settings.
With UI-dragger I don’t mean the UIs that you can drag around your screen, I mean a setting-dragger that you can only drag in a straight line. Sorry if the title was unclear.
You can do it by using AbsolutePosition and AbsoluteSize.
Here:
local Player = game:GetService("Players").LocalPlayer
local mouse = Player:GetMouse();
local IsDragging = false
local Dragger = script.Parent
local Frame = Dragger.Parent
Dragger.MouseButton1Down:Connect(function()
IsDragging = true
end)
Dragger.MouseButton1Up:Connect(function()
IsDragging = false
end)
mouse.Move:Connect(function()
if IsDragging then
local newPositionX = math.clamp((mouse.X - Frame.AbsolutePosition.X)/Frame.AbsoluteSize.X, 0, 1)
Dragger.Position = UDim2.fromScale(newPositionX, Dragger.Position.Y.Scale);
end
end)
Hope this helped.