Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dragging one part, equals dragging the whole other parts #6

Open
LawMixer opened this issue Jun 18, 2023 · 1 comment
Open

Dragging one part, equals dragging the whole other parts #6

LawMixer opened this issue Jun 18, 2023 · 1 comment

Comments

@LawMixer
Copy link

https://streamable.com/d7yt49

Right now, I want to move the yellow box, and not the black box.

local LocalPlayer = game:GetService("Players").LocalPlayer

local Snapdragon = require(game.ReplicatedStorage:WaitForChild("Snapdragon"))
local storeTbl = require(script:FindFirstChild("2dArray"))

local InventoryFunc = require(script.InvMod)

local controller2 = Snapdragon.createDragController(script.Parent.ItemPlaceholder) 
controller2:Connect()

local prevIndex = 0 

local function getIndex(number)
	if number == 1 then 
		return 1, 1
	elseif number == 2 then 
		return 1, 2
	elseif number == 3 then 
		return 1, 3
	elseif number == 4 then 
		return 1, 4
	elseif number == 5 then 
		return 2, 1 
	elseif number == 6 then 
		return 2, 2
	elseif number == 7 then 
		return 2, 3
	elseif number == 8 then 
		return 2, 4
	end
end

controller2.DragEnded:Connect(function(callback)
	local d = script.Parent.ItemPlaceholder

	local closestObj = InventoryFunc:whichSlotisClosest(controller2.gui.AbsolutePosition)
	local indexNum = tonumber(closestObj.Name)

	local overlappingUIs = InventoryFunc:areFramesOverlapping(controller2.gui)

	if d:FindFirstChild("Config").Shape.Value == "Rect" then 
		local indexNumber, indexNumber2 = getIndex(indexNum)

		if storeTbl[1][indexNumber2] == true and storeTbl[2][indexNumber2] == true then 
			controller2.gui.Position = closestObj.Position
			storeTbl[1][indexNumber2] = false 
			storeTbl[2][indexNumber2] = false 
			
			
			if prevIndex ~= 0 then 
				storeTbl[1][prevIndex] = true  
				storeTbl[2][prevIndex] = true  

				prevIndex = indexNumber2
			else 
				prevIndex = indexNumber2
			end
		end
	end 
	
end)

local controller = Snapdragon.createDragController(script.Parent.ItemPlaceholder2) 
controller:Connect()

local prevIndex23, prevIndex12 = 0, 0

controller.DragEnded:Connect(function(callback)
	local d = script.Parent.ItemPlaceholder2

	local closestObj = InventoryFunc:whichSlotisClosest(controller.gui.AbsolutePosition)
	local indexNum = tonumber(closestObj.Name)

	local overlappingUIs = InventoryFunc:areFramesOverlapping(controller.gui)


	if d:FindFirstChild("Config").Shape.Value == "Square" then
		local indexNumber, indexNumber2 = getIndex(indexNum) 
		
		print(storeTbl)
		
	end
end)
@LawMixer
Copy link
Author

My hierarchy: https://i.imgur.com/OKBrr8E.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant