Frame not moving correctly with a Inventory System

Hello, I’m trying to make an inventory system. I made the system move the item and drop but the frame is not in the same position as my mouse. Can anyone help?

https://gyazo.com/cb70bb203bbf9952dc83b7672f224475

Code i used:

Image.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)

I’m gonna take a guess and assume your issue is because you aren’t taking into account the offset from GuiInset at the top of the screen. There’s a simple way you can get the true position like this:

local GuiService = game:GetService("GuiService")
local offset = GuiService:GetGuiInset()
local mousePosition = Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(0,offset.Y)

Hope this helps! If you have any questions feel free to ask.

local Frame : Frame = script.Parent

local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()

local UIS = game:GetService("UserInputService")

local IsInside
local X,Y = 0,0

Frame.MouseEnter:Connect(function() IsInside = true end)
Frame.MouseEnter:Connect(function() IsInside = false end)

Mouse.Button1Down:Connect(function()
	X,Y = Mouse.X - Frame.AbsolutePosition.X,Mouse.Y - Frame.AbsolutePosition.Y
end)

Mouse.Move:Connect(function()
	if IsInside and UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) then Frame.Position = UDim2.new(0,Mouse.X - X,0,Mouse.Y - Y) end
end)

or you just can use this module