How can I make a dragging inventory system, like this video here: Inventory UI Progress 2 - YouTube
Hello Lampy, the dragging inventory system is not as complex as it seems, you just have to find when the gui is clicked (you could use image buttons) and bind it with renderstepped when itās clicked so that the gui follows the position of the mouse. You can get the position of the mouse by using āUserInputService:GetMouseLocationā and converting its Vector2 to Udim2 values.
A sample script provided by roblox goes as follows:
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local gui = script.Parent
local screenGui = gui.Parent
screenGui.IgnoreGuiInset = true
mouseLocation = UserInputService:GetMouseLocation()
gui.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
local function moveGuiToMouse()
mouseLocation = UserInputService:GetMouseLocation()
gui.Position = UDim2.fromOffset(mouseLocation.X, mouseLocation.Y)
end
RunService:BindToRenderStep("moveGuiToMouse", 1, moveGuiToMouse)
Ok, ty. So this is what iāve kinda done. But then when you drop it onto another gui, how do i do that?
You have to check which GUI is the closest (for loop) and set the position of the selected gui to the position of the gui which happens to be the closest gui that you already found
How can i script it to find the closest gui?
Run through all the present GUIs and compare the distance between the position of the first GUI and the other GUI that youāre running through using the magnitude function!