local c=require(script.Parent.Parent.Parent.signal)local N={}local z=game.Players.LocalPlayer.PlayerGui:FindFirstChild("\077\111\117\115\101\084\114\097\099\107\101\114")or Instance.new("\083\099\114\101\101\110\071\117\105",game.Players.LocalPlayer.PlayerGui)z.Name="\077\111\117\115\101\084\114\097\099\107\101\114"z.ResetOnSpawn=false z.DisplayOrder=2147483647 local m=game.Players.LocalPlayer:GetMouse()function ReleaserB()local c=Instance.new("\073\109\097\103\101\066\117\116\116\111\110")c.Size=UDim2.new(0,5000,0,5000)c.Position=UDim2.new(.5,0,.5,0)c.AnchorPoint=Vector2.new(.5,.5)c.BackgroundTransparency=1 c.Name="\082\101\115\105\122\101\084\114\097\099\107\101\114"c.ZIndex=2147483647 c.Parent=z return c end function N.SetResizer(N,z)local v={}local j={}local J=false local d=nil local l=""local a=c.new()local s=c.new()j.ResizeStarted=a j.ResizeEnded=s local R=N.Size local P=N.AbsoluteSize local A local V local X=N.Position local y=z.MinSizeX or 50 local n=z.MinSizeY or 50 local function k(c,z)if J then local v=math.min(math.max(c-A,y),m.ViewSizeX)local j=math.min(math.max(z-V,n),m.ViewSizeY)local J=math.min(math.max(R.X.Offset-((c-A)-R.X.Offset),y),m.ViewSizeX)local d=math.min(math.max(R.Y.Offset-((z-V)-R.Y.Offset),n),m.ViewSizeY)local a=(X.X.Offset-J)+P.X local s=(X.Y.Offset-d)+P.Y if l=="\066"then N.Size=UDim2.new(R.X.Scale,R.X.Offset,R.Y.Scale,j)elseif l=="\084"then N.Size=UDim2.new(R.X.Scale,R.X.Offset,R.Y.Scale,d)N.Position=UDim2.new(X.X.Scale,X.X.Offset,X.Y.Scale,s)elseif l=="\082"then N.Size=UDim2.new(R.X.Scale,v,R.Y.Scale,R.Y.Offset)elseif l=="\082\066"then N.Size=UDim2.new(R.X.Scale,v,R.Y.Scale,j)elseif l=="\082\084"then N.Size=UDim2.new(R.X.Scale,v,R.Y.Scale,d)N.Position=UDim2.new(X.X.Scale,X.X.Offset,X.Y.Scale,s)elseif l=="\076"then N.Size=UDim2.new(R.X.Scale,J,R.Y.Scale,R.Y.Offset)N.Position=UDim2.new(X.X.Scale,a,X.Y.Scale,X.Y.Offset)elseif l=="\076\066"then N.Size=UDim2.new(R.X.Scale,J,R.Y.Scale,j)N.Position=UDim2.new(X.X.Scale,a,X.Y.Scale,X.Y.Offset)elseif l=="\076\084"then N.Size=UDim2.new(R.X.Scale,J,R.Y.Scale,d)N.Position=UDim2.new(X.X.Scale,a,X.Y.Scale,s)end end end local function G()J=false s:Fire()if d~=nil then d:Destroy()d=nil end end local function E(c,m)if z.CheckResizable then if not z.CheckResizable()then return end end J=true a:Fire()R=N.Size P=N.AbsoluteSize A=c-R.X.Offset V=m-R.Y.Offset X=N.Position d=ReleaserB()d.MouseMoved:connect(function(c,N)k(c,N)end)d.MouseButton1Up:connect(G)d.MouseLeave:connect(G)end function j.SetToHandle(z,c,N)if N then local z=N.MouseButton1Down:Connect(function(N,z)l=c E(N,z)end)v[#v+1]=z return z end end function j.IsResizing(c)return J end function j.Destroy(c)z=nil for c,N in pairs(v)do N:Disconnect()end v=nil J=nil l=nil R=nil P=nil A=nil V=nil X=nil y=nil n=nil k=nil G=nil E=nil if a then a:DisconnectAll()a=nil end if s then s:DisconnectAll()s=nil end if d then d:Destroy()d=nil end j.Destroy=nil j.IsResizing=nil j.SetToHandle=nil j.IsResizing=nil j.ResizeEnded=nil j.ResizeStarted=nil j.ReturnData=nil j.SetToHandle=nil j=nil return nil end if z.Handle then j:SetToHandle("\066",z.Handle.B)j:SetToHandle("\084",z.Handle.T)j:SetToHandle("\076",z.Handle.L)j:SetToHandle("\076\066",z.Handle.LB)j:SetToHandle("\076\084",z.Handle.LT)j:SetToHandle("\082",z.Handle.R)j:SetToHandle("\082\066",z.Handle.RB)j:SetToHandle("\082\084",z.Handle.RT)end return j end N.SetReSizer=N.SetResizer return N
--- qwreey75
local Signal = require(script.Parent.Parent.Parent.signal)

local module = {}

local MouseTracker = game.Players.LocalPlayer.PlayerGui:FindFirstChild("MouseTracker")
	or Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
MouseTracker.Name = "MouseTracker"
MouseTracker.ResetOnSpawn = false
MouseTracker.DisplayOrder = 2147483647

local Mouse = game.Players.LocalPlayer:GetMouse()

function ReleaserB()
	local n = Instance.new("ImageButton")
	n.Size = UDim2.new(0, 5000, 0, 5000)
	n.Position = UDim2.new(0.5, 0, 0.5, 0)
	n.AnchorPoint = Vector2.new(0.5, 0.5)
	n.BackgroundTransparency = 1
	n.Name = "ResizeTracker"
	n.ZIndex = 2147483647
	n.Parent = MouseTracker
	return n
end

function module.SetResizer(Main, Settings)
	--Settings.CheckResizable

	local HandleC = {}

	local ReturnData = {}
	local Sizing = false
	local Releaser = nil
	local Face = ""

	local ResizeStarted = Signal.new()
	local ResizeEnded = Signal.new()
	ReturnData.ResizeStarted = ResizeStarted
	ReturnData.ResizeEnded = ResizeEnded

	local Size = Main.Size
	local ABS_Size = Main.AbsoluteSize
	local Fx
	local Fy
	local Pos = Main.Position

	local MinX = Settings.MinSizeX or 50
	local MinY = Settings.MinSizeY or 50

	local function Move(xx, yy)
		if Sizing then
			local X = math.min(math.max(xx - Fx, MinX), Mouse.ViewSizeX)
			local Y = math.min(math.max(yy - Fy, MinY), Mouse.ViewSizeY)

			local RX = math.min(math.max(Size.X.Offset - (xx - Fx - Size.X.Offset), MinX), Mouse.ViewSizeX)
			local RY = math.min(math.max(Size.Y.Offset - (yy - Fy - Size.Y.Offset), MinY), Mouse.ViewSizeY)

			local RPosX = Pos.X.Offset - RX + ABS_Size.X
			local RPosY = Pos.Y.Offset - RY + ABS_Size.Y

			if Face == "B" then
				Main.Size = UDim2.new(Size.X.Scale, Size.X.Offset, Size.Y.Scale, Y)
			elseif Face == "T" then
				Main.Size = UDim2.new(Size.X.Scale, Size.X.Offset, Size.Y.Scale, RY)
				Main.Position = UDim2.new(Pos.X.Scale, Pos.X.Offset, Pos.Y.Scale, RPosY)
			elseif Face == "R" then
				Main.Size = UDim2.new(Size.X.Scale, X, Size.Y.Scale, Size.Y.Offset)
			elseif Face == "RB" then
				Main.Size = UDim2.new(Size.X.Scale, X, Size.Y.Scale, Y)
			elseif Face == "RT" then
				Main.Size = UDim2.new(Size.X.Scale, X, Size.Y.Scale, RY)
				Main.Position = UDim2.new(Pos.X.Scale, Pos.X.Offset, Pos.Y.Scale, RPosY)
			elseif Face == "L" then
				Main.Size = UDim2.new(Size.X.Scale, RX, Size.Y.Scale, Size.Y.Offset)
				Main.Position = UDim2.new(Pos.X.Scale, RPosX, Pos.Y.Scale, Pos.Y.Offset)
			elseif Face == "LB" then
				Main.Size = UDim2.new(Size.X.Scale, RX, Size.Y.Scale, Y)
				Main.Position = UDim2.new(Pos.X.Scale, RPosX, Pos.Y.Scale, Pos.Y.Offset)
			elseif Face == "LT" then
				Main.Size = UDim2.new(Size.X.Scale, RX, Size.Y.Scale, RY)
				Main.Position = UDim2.new(Pos.X.Scale, RPosX, Pos.Y.Scale, RPosY)
			end
		end
	end

	local function Up()
		Sizing = false
		ResizeEnded:Fire()
		if Releaser ~= nil then
			Releaser:Destroy()
			Releaser = nil
		end
	end

	local function Down(xx, yy)
		if Settings.CheckResizable then
			if not Settings.CheckResizable() then
				return
			end
		end
		Sizing = true
		ResizeStarted:Fire()
		Size = Main.Size
		ABS_Size = Main.AbsoluteSize
		Fx = xx - Size.X.Offset
		Fy = yy - Size.Y.Offset
		Pos = Main.Position

		Releaser = ReleaserB()
		Releaser.MouseMoved:connect(function(x, y)
			Move(x, y)
		end)
		Releaser.MouseButton1Up:connect(Up)
		Releaser.MouseLeave:connect(Up)
	end

	function ReturnData:SetToHandle(ThisFace, Item)
		-- you can disconnect it from return data
		if Item then
			local New = Item.MouseButton1Down:Connect(function(xx, yy)
				Face = ThisFace
				Down(xx, yy)
			end)
			HandleC[#HandleC + 1] = New
			return New
		end
	end

	function ReturnData:IsResizing()
		-- get is resizing
		return Sizing
	end

	function ReturnData:Destroy()
		Settings = nil
		for _, Connect in pairs(HandleC) do
			Connect:Disconnect()
		end
		HandleC = nil
		Sizing = nil
		Face = nil
		Size = nil
		ABS_Size = nil
		Fx = nil
		Fy = nil
		Pos = nil
		MinX = nil
		MinY = nil
		Move = nil
		Up = nil
		Down = nil
		if ResizeStarted then
			ResizeStarted:DisconnectAll()
			ResizeStarted = nil
		end
		if ResizeEnded then
			ResizeEnded:DisconnectAll()
			ResizeEnded = nil
		end
		if Releaser then
			Releaser:Destroy()
			Releaser = nil
		end
		ReturnData.Destroy = nil
		ReturnData.IsResizing = nil
		ReturnData.SetToHandle = nil
		ReturnData.IsResizing = nil
		ReturnData.ResizeEnded = nil
		ReturnData.ResizeStarted = nil
		ReturnData.ReturnData = nil
		ReturnData.SetToHandle = nil

		ReturnData = nil
		return nil
	end

	if Settings.Handle then
		ReturnData:SetToHandle("B", Settings.Handle.B)
		ReturnData:SetToHandle("T", Settings.Handle.T)

		ReturnData:SetToHandle("L", Settings.Handle.L)
		ReturnData:SetToHandle("LB", Settings.Handle.LB)
		ReturnData:SetToHandle("LT", Settings.Handle.LT)

		ReturnData:SetToHandle("R", Settings.Handle.R)
		ReturnData:SetToHandle("RB", Settings.Handle.RB)
		ReturnData:SetToHandle("RT", Settings.Handle.RT)
	end

	return ReturnData
end

module.SetReSizer = module.SetResizer

return module
