I have an imagebutton inside a frame that when I click and drag it will follow, this works perfectly when it is not parented with the frame. When it’s in the frame the gui will skip and go in the opposite direction of the mouse.
video
local InventoryGui = script.Parent
local InventoryFrame = InventoryGui.Inventory
--local Topbar = InventoryGui.TopToolbar
local Dragging = false
for i,v in pairs(InventoryFrame:GetChildren()) do
if v:IsA("ImageButton") then
v.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
Dragging = true
end
end)
v.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
v.Position = UDim2.new(0, input.Position.X, 0, input.Position.Y)
print(input.Position)
end
end)
v.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
v.Position = UDim2.new(0, input.Position.X, 0, input.Position.Y)
Dragging = false
end
end)
end
end