How To Make A Draggable GUI?

So I was wondering, is there anyway to create a draggable GUI? Should I just look for a script on the toolbox or get professional help from here? So I chose the DevForum.

So, does anyone know how to do this?

8 Likes

You can use, Mouse Enter function for the frame, and mouse leave, so if it enters, youcan set a variable to ‘true’

And maybe using Mouse.Button1Down or UserinputService, with a loop, while the variable is true, move the Frame position according to mouse.Y and mouse.X

2 Likes

There’s an open sourced module just for this

22 Likes
-- >> Rename frame to the frame you want to be draggable

frame = script.Parent.Frame
frame.Draggable = true
frame.Active = true
frame.Selectable = true
10 Likes

I think Draggable is deprecated( correct me if I’m wrong)

8 Likes

The Draggable property has been deprecated and should not be used.

3 Likes

Indeed. Draggable is no longer here. It was removed.

RIP Draggable Property - The Most Valuable Property

15 Likes

The draggable property has been deprecated as we can see. Use this snippet from Tiffblocks instead (i couldnt find the original forum) and also if you dont wanna use module this is a solution:

 local UserInputService = game:GetService("UserInputService")

        local gui = script.Parent

        local dragging
        local dragInput
        local dragStart
        local startPos

        local function update(input)
        	local delta = input.Position - dragStart
        	gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end

        gui.InputBegan:Connect(function(input)
        	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        		dragging = true
        		dragStart = input.Position
        		startPos = gui.Position
        		
        		input.Changed:Connect(function()
        			if input.UserInputState == Enum.UserInputState.End then
        				dragging = false
        			end
        		end)
        	end
        end)

        gui.InputChanged:Connect(function(input)
        	if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
        		dragInput = input
        	end
        end)

        UserInputService.InputChanged:Connect(function(input)
        	if input == dragInput and dragging then
        		update(input)
        	end
        end)
41 Likes

for me, the draggable property on frames still works. u just need to change the .Active property to true

3 Likes

Try not to use deprecated features.

9 Likes

why? i use draggable sometimes. Nothing bad happened.

1 Like

You can use it, it’s just deprecated so it could suddenly cause disruptions in the experience.

3 Likes

oh okay then. thank you for letting me know.

6 Likes

Deprecated code can lead to problems and make the program or task not work. Using better functions and proper services improves preformance even if it’s more lines of code.

2 Likes

Roblox’s draggable feature is not good. If you drag too fast it will not register because your mouse slid off it. I use draggify because I love the smooth draggability.

1 Like