I want to make a draggable gui
When I make it drag it just goes to the top left of the screen.
Start:
What I get:
I went on devforum.roblox.com
My Script Analysis has no errors same as my Output. I am trying to set my GUI’s position to the mouse to make it draggable but it only goes to the top left. Am I missing anything (sorry for not much detail)
local Player = game:GetService("Players").LocalPlayer
local Mouse = Player:GetMouse()
local UserInputService = game:GetService('UserInputService')
local hold = false
function drag()
if hold == false then return end
script.Parent.Parent.Position = UDim2.new(0,Mouse.Hit,0,Mouse.Hit)
end
function inputBegan(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
hold = true
end
end
function inputEnded(input)
local inputType = input.UserInputType
if inputType == Enum.UserInputType.MouseButton1 then
hold = false
end
end
UserInputService.InputBegan:Connect(inputBegan)
UserInputService.InputEnded:Connect(inputEnded)
script.Parent.MouseMoved:Connect(drag)