How to I make it so you can only move 1 window at once?

Hiya, this is my issue:


How can I make it so I can only drag one window at once? Thanks :slight_smile:

Current Code (Found in each window)
local UserInputService = game:GetService("UserInputService")

local gui = script.Parent
local topbar = gui.Topbar

local dragging
local dragInput
local dragStart
local startPos

local function update(input)
	local delta = input.Position - dragStart
	gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end

topbar.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		for _,o:Frame in pairs(script.Parent.Parent:GetChildren()) do
			o.ZIndex = 1
		end
		script.Parent.ZIndex = 2
		
		dragging = true
		dragStart = input.Position
		startPos = gui.Position

		input.Changed:Connect(function()
			if input.UserInputState == Enum.UserInputState.End then
				dragging = false
			end
		end)
	end
end)

topbar.InputChanged:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
		dragInput = input
	end
end)

UserInputService.InputChanged:Connect(function(input)
	if input == dragInput and dragging then
		update(input)
	end
end)
1 Like

@frrazers Hey mate Nice mate! Why do u want it all together in together???

If you want a simple solution for that you should change ZIndex of every frame to something like 1.1, 1.2 and 1