Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Hi, I'm making a GUI right now, but I want it to be draggable, Help me?

Hi, I'm making a GUI right now, but I want it to be dragable, but the current script I have isn't working.

frame = script.Parent.Frame
frame.Draggable = true

-- Draggable Frame

Could you help me?

4 comments

0

If that doesn't work try moving the frame when the mouse moves via UserInputService.InputBegan

0

What does that mean? I just a learner scripter xD

0

Ok, I fixed it.

0

If so edit your title so it contains [SOLVED] so people know it has been solved.

1 answer

Draggable has sadly Removed. but you can use this:

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)

you should add this script in specific object. (from https://devforum.roblox.com/t/draggable-property-is-hidden-on-gui-objects/107689/4)

This discussion is preserved as it was. New answers, comments, and votes are closed.