How Do I Make A Drag Bar?

Im working on a sort of dragable bar in roblox and depending on the position of the point returns a number but I cant seem to figure out how to get the number or even make it dragable.

this is my script so far.

--Objects//

local Parent = script.Parent

local MainParent = Parent.Parent

--Mouse

local Mouse = game.Players.LocalPlayer:GetMouse()

--Services

local RunService = game:GetService("RunService")

--Values//

local IsTouching = false

local IsDragging = false

local CurrentPosition = Parent.Position

local MaxNumber = 120

local MinNumber = 0

--Functions//

function Drag()

local X, Y = Mouse.X, MainParent.Position.Y

Parent.Position = UDim2.new(X, Y)

end

Mouse.Button1Down:Connect(function()

if IsTouching then

IsDragging = true

RunService:BindToRenderStep("DragObject", 1, Drag)

end

end)

Mouse.Button1Down:Connect(function()

if IsDragging then

IsDragging = false

RunService:UnbindFromRenderStep("DragObject")

end

end)

----------------------------------------------------------------

--Style Functions

Parent.MouseEnter:Connect(function()

Parent.BackgroundColor3 = Color3.fromRGB(27, 27, 27)

IsTouching = true

end)

Parent.MouseLeave:Connect(function()

Parent.BackgroundColor3 = Color3.fromRGB(46, 46, 46)

IsTouching = false

end)

If you need any more information on what I need help with then please ask.

1 Like

You mean something like a slider? being able to drag it and return its current value?

I did check this module which is pretty interesting in order to learn how to build a slider, you could use it to create your sliders or to learn how to create your own method. Check this module

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