Mouse's Y position inconsistent when positioning gui to it

Hi, I have an inventory script where players drag around inventory items I’ll let you see the problem here. Notice how the gui’s Y position changes as the mouse position goes lower.

UI Testing - Roblox Studio 2022-07-23 23-57-32 (Video is messed up sorry)

I am using a heavily modified version of this script so here are the most important parts. How To Make A Draggable GUI? - #9 by MrchipsMa

local function update(input, gui)
	local delta = input.Position - dragStart
	gui.Position = UDim2.new(startPosX, -1.5 + delta.X, startPosY, delta.Y)
end

--later in the script
startPosX = mouse.X/mouse.ViewSizeX
startPosY = mouse.Y/mouse.ViewSizeY

I am parenting the GUI to the ScreenGui which in which it doesn’t matter whether IgnoreGuiInset enabled or disabled.

I just want it to go a little left of the mouse and while the startPosX works, the startPosY is just not working.
Thanks!

This is the X Scale, not the offset. Change this to offset and make sure the scale is positioned at 0, 0.

I recommend not finding the start position of the mouse, and the GUI instead. This is what the scale should be.

Yes I know that’s why I made the mouse position into scale using viewsize. If I use the GUI’s position it won’t snap to where I want on the mouse that’s why I want to use the mouse’s position.

If I similarly use basically this same script with different offsets for my mouse hover position it works perfectly. That’s why I’m confused.

1 Like

Tried it slightly your way leaning more on offset and I found a way that makes the position change so minor it’s unnoticeable thanks!

1 Like