I’m attempting to make a Tetris styled inventory, but I’m stuck on moving to other inventory slots. Any help would be great.
Move code:
ItemBox.DragBegin:Connect(function()
Dragging = true
for i, v in pairs(script.Parent.Inventory.PreSliderFrame.SliderFrame:GetChildren()) do
if v:IsA("Frame") then
v.MouseEnter:Connect(function() -- There's probably a better way to do this but I'm not sure.
if Dragging then
BoxDraggedOn = v
end
end)
end
end
end)
ItemBox.DragStopped:Connect(function()
Dragging = false
print(BoxDraggedOn)
ItemBox.Position = UDim2.new(0, BoxDraggedOn.AbsolutePosition.X, 0, BoxDraggedOn.AbsolutePosition.Y)
end)
Seems to me you’re having a Gui Inset problem, try decreasing/increasing the position by 36 pixels on the Y axis
ItemBox.Position = UDim2.new(0, BoxDraggedOn.AbsolutePosition.X, 0, BoxDraggedOn.AbsolutePosition.Y - 36)
-- If it offsets even more then +36
Yes, GuiObject.MouseEnter isn’t very consistent and it is fired even if there’s another GuiObject on top.
You should use GuiObject.InputChanged with UserInputType of MouseMovement and use PlayerGui:GetGuiObjectsAtPosition(x, y) to check if there’s any GuiObject on top
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if Input.KeyCode == Enum.KeyCode.R and IsTyping ~= true and Dragging == true then
ItemBox.Rotation += 90
end
end)
Also it’s better if you convert this position from Offset into Scale, otherwise when the UI changes in size or the player screen resolution changes it’d look out of place