Greetings, I’m attempting to make a Tetris styled inventory like Tarkov or Resident Evil, but I’m having some issues, and one of them is that I’m not sure how to determine on what cell a player is dragging so I can determine on what inventory cell I should put it in.
Right now, it only is the top, or the bottom left corner of the item, but how would I determine if it was the right, or if the item was more than 2 cells, the middle or any of the others?
with this:
you could have if statements to check the roration of the item and slot before assigning
No, no. This isn’t what I mean. In the video, I was showcasing that it was only moving based on origin of it, in this case, the left side of it, and it rotates 90 degrees, the origin is moved to the bottom.
However, I don’t want there to be an “origin” I want to know what part of the item is being clicked on, so I can move it to there.
I’m not good at explaining, so here’s a showcase of my problem, to see if it’s any better.
I realize I should’ve included my code.
ItemBox.DragBegin:Connect(function()
Dragging = true
StartBox = ItemBox.Position
for i, v in pairs(script.Parent.Inventory.PreSliderFrame.SliderFrame:GetChildren()) do
if v:IsA("Frame") then
v.MouseEnter:Connect(function()
CellDragged = v
if Dragging then
BoxDraggedOn = v
for i,v in pairs(script.Parent:GetChildren()) do
if v.Name == "Item" and not ItemBox then
print("b")
BoxDraggedOn = v
end
end
end
end)
end
end
end)
ItemBox.DragStopped:Connect(function()
Dragging = false
if BoxDraggedOn and BoxDraggedOn.Name ~= "Item" then
ItemBox.Position = UDim2.new(0, BoxDraggedOn.AbsolutePosition.X, 0, BoxDraggedOn.AbsolutePosition.Y + 36)
else
ItemBox.Position = StartBox
end
end)
UserInputService.InputBegan:Connect(function(Input, IsTyping)
if Input.KeyCode == Enum.KeyCode.R and IsTyping ~= true and Dragging == true then
if ItemBox.Rotation == 0 then
ItemBox.Rotation = 90
ItemBox.AnchorPoint = Vector2.new(0.24, 0.5)
else
ItemBox.Rotation = 0
ItemBox.AnchorPoint = Vector2.new(0, 0)
end
end
end)
end
If you need me to try explain it better, then I will try.