How do i move gui with mouse

is there any way that my gui(a windows like cmd) move with mouse like HD admin or windows cmd??

i tried position my gui every tick but the gui’s center go to my mouse

i tried anything but nothing helped

while wait() do
     Gui.AnchorPoint = Vector2.new(.5,.5)
     Gui.Position = UDIm2.new(0,UserInputService:GetMouseLocation().X,0,UserInputService:GetMouseLocation.Y)
end

thanks

Maybe trying deleting the anchor point?

1 Like

This might help you they made an example on how to move it with the mouse.

UI.Selectable = true
UI.Active = true
UI.Draggable = true
3 Likes

.Draggable is deprecated, so I wouldn’t use that.
Here’s a script that might work for you, I’d also just consider reading through this thread.

1 Like

It still works for me, its very simple.

1 Like

this is a local script put it in your gui thats it :

local Drag = script.Parent.Parent.Frame
gsCoreGui = game:GetService(“CoreGui”)
gsTween = game:GetService(“TweenService”)
local UserInputService = game:GetService(“UserInputService”)
local dragging
local dragInput
local dragStart
local startPos
local function update(input)
local delta = input.Position - dragStart
local dragTime = 0.04
local SmoothDrag = {}
SmoothDrag.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
local dragSmoothFunction = gsTween:Create(Drag, TweenInfo.new(dragTime, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), SmoothDrag)
dragSmoothFunction:Play()
end
Drag.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
dragging = true
dragStart = input.Position
startPos = Drag.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
Drag.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 and Drag.Size then
update(input)
end
end)

1 Like

thank you so much! i forget that

Just because it works does not mean it is deprecated, it could break anytime in the future since it is not going to be worked on again

deprecated means no more updates. It will perish sooner or later.

mobile user cant move frame anymore if u still using it