As you can see, the GUI is way far away from the mouse. This is completely unexpected and nonsensical. Considering the Mouse.X and Mouse.Y should return the offset position, this makes no sense.
Well I haven’t used mouse service that much but if it returns offset then try only putting offset values to your frame position and maybe size Else the mouse is getting the 3D position.
Thank you for giving me this resource, and I assure you, I’ve already seen and used it in the past. I want to actually do it myself, as I think it’s better to learn not to. Thanks again though.
actually TBH its kind of annoying when people spam modules for dragging GUI. It basically says, “Hey, I’m ignorant and lazy, and cant script!” Like bro, don’t be an NPC. there were probably a hundred other bots ready to spam this same module, ready to be deployed.
To be fair, you can always just learn from the module and see what it does differently by looking at the code.
If you want direct help for your script without quick solutions, mention that in the post.
I am having trouble determining what Is wrong. I think something along the lines of using AbsoluteSize, AbsolutePoint, AbsolutePosition, but I’m really unsure.
I have tested my following scripts and they work fine from what I’ve tested
With Tween:
local TweenService = game:GetService("TweenService")
local button = Instance.new("TextButton", Instance.new("ScreenGui", game.StarterGui))
button.Size = UDim2.fromScale(.5, .5)
button.AnchorPoint = Vector2.new(.5, .5)
local mouse
local mouseHeld = false
local a = button.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = true
while mouseHeld == true do
task.wait()
mouse = game:GetService("UserInputService"):GetMouseLocation()
TweenService:Create(button, TweenInfo.new(.5, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), {Position = UDim2.new(0, mouse.X, 0, mouse.Y)}):Play()
end
end
end)
local b = button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = false
while mouseHeld == false do
task.wait()
end
end
end)
Without Tween:
local TweenService = game:GetService("TweenService")
local button = Instance.new("TextButton", Instance.new("ScreenGui", game.StarterGui))
button.Size = UDim2.fromScale(.5, .5)
button.AnchorPoint = Vector2.new(.5, .5)
local mouse
local mouseHeld = false
local a = button.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = true
while mouseHeld == true do
task.wait()
mouse = game:GetService("UserInputService"):GetMouseLocation()
button.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
end
end
end)
local b = button.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseHeld = false
while mouseHeld == false do
task.wait()
end
end
end)
Hey, I tried your method but Roblox really hates me.
Here is what I did:
while dragging do
local mousePos = game:GetService("UserInputService"):GetMouseLocation()
script.Parent.Position = UDim2.new(0, mousePos.X, 0, mousePos.Y)
task.wait(.1)
end