I get a problem about scripting the gui
I am scripting a drag frame but it work bad.
There is the script
-
local MouseDown = false
-
local UIS = game:GetService(“UserInputService”)
-
local RunService = game:GetService(“RunService”)
-
local CurrentBox = script.Parent
-
UIS.InputBegan:Connect(function(input)
-
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-
MouseDown = true`Preformatted text` -
end
-
end)
-
UIS.InputEnded:Connect(function(input)
-
if input.UserInputType == Enum.UserInputType.MouseButton1 then -
MouseDown = false -
end -
end)
-
RunService.RenderStepped:Connect(function()
-
if MouseDown then -
print(Mouse.x/1000) -
print(Mouse.y/1000) -
CurrentBox.Position = UDim2.new(Mouse.x/1000,0,Mouse.y/1000,0) -
end -
end)
Frame position is not same of the mouse on screen.


