You could try using hover functions or on button up, but the most reliable way you will find is using UserInputService to track mouse movement and when the button is released.
Once you have the mouse x and y, you can iterate over your inventor’s buttons to see if the mouse is over a certain slot.
Any further help will require code, as #help-and-feedback:scripting-support is not meant for giving out code. I can, however, modify your code to help you.
Aye, glad to see Joshua finally found another scripter for Quarantined… I was actually the person that done the first version of that inventory system…
Anyway the end result is kinda easy to achieve… Just as @REALTimothy0812 explained, you just need to be able to track the movement of the mouse while you are monitoring if the Mouse button is Down or up… This is not the place to give free scripts of course, but I can kinda explain the structure of it…
local mouse = game.Players.LocalPlayer:GetMouse()
local InButton = false
local MouseDown = false
button.MouseEnter:Connect(function()
InButton = true
end)
button.MouseLeave:Connect(function()
InButton = false
end)
button.MouseButton1Down:Connect(function()
MouseDown = true
spawn(function()
repeat
--Position Button same place of the mouse
wait()
until MouseDown == false
end)
end)
button.MouseButton1Up:Connect(function()
MouseDown = false
--If the button is close enough to the space open, reposition it to the exact place.
end)
This is off the top of my head written right here so there may be bugs… This should at least give you the general idea of the operations needed to achieve the result