Mouse.X and Mouse.Y dont accurately get the position of the mouse

Hello, I’m trying to make a drag GUI element however the position of the mouseX and mouseY are not accurate. Let me show you what I mean:

Here is my script:

local function animateMouse()		
	local move = localPlayer.PlayerGui.ScreenGui.mobileElements.move
		
	while actioning do
		local mouse = localPlayer:GetMouse()
		move.Position = UDim2.new(0, mouse.X, 0, mouse.Y)
		task.wait()
	end
end

as you can see, I am simply setting the position to Mouse.X and Mouse.Y.

Lets look at what this looks like:
image

as you can see, it does not accurately put it on the mouse.

1 Like

Try adding + 36 as the screen gui may have ignorguilnset enabled. And if you want the image in the mouse change anchors point to 0.5,0.5. Last thing If ‘mobile elements’ is a frame check if it isn’t resized

2 Likes

that didnt work. I just used

local mouse = UIS:GetMouseLocation()

which gets a more accurate location of the mouse

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.