Plugin UI change when it hits a certain size

I am developing a plugin right now and I am using it as a widget. It is way to small if you scale it down but I want it to be able to scale down a lot. Is there any way to detect when the widget is a certain size and execute something. Any help is amazing. Code down below:



--Creates The Plugin--
local toolbar = plugin:CreateToolbar("HyperStudio's") 
local CreatePlugin = toolbar:CreateButton("UI QuickClick", "UI QuickClick", "rbxassetid://13842694602 ") 
local CHS = game:GetService("ChangeHistoryService")
local Selection = game:GetService("Selection")

--Sets Plugin--
local widgetInfo = DockWidgetPluginGuiInfo.new(
	Enum.InitialDockState.Float, -- Widget will be initialized in floating panel
	false, -- Widget will be initially enabled
	false, -- Don't override the previous enabled state
	200, -- Default width of the floating window
	200, -- Default height of the floating window
	200, -- Minimum width of the floating window
	200 -- Minimum height of the floating window 
)

-- Create new widget GUI
local Main = plugin:CreateDockWidgetPluginGui("TestWidget", widgetInfo) 
Main.Title = "UI QuickClick"
Main.Enabled = not Main.Enabled
local MainUI = script.Parent.PluginUI.PluginCoreUI
local MainUISidebar = script.Parent.PluginUI.PluginCoreUI.SideBar









MainUI.Parent = Main
local isOn = false 

wait(0.1) 

CreatePlugin.Click:Connect(function()
	isOn = not isOn 
	CreatePlugin:SetActive(isOn) 
	Main.Enabled = isOn
end)




1 Like

GuiBase2D’s have AbsoluteSize, which is the size of the Gui in pixels on the screen.
You could just do this and it would probably work:

local SomeGui: GuiBase2d

SomeGui:GetPropertyChangedSignal("AbsoluteSize"):Connect(function ()
	local X = SomeGui.AbsoluteSize.X
	local Y = SomeGui.AbsoluteSize.Y
	--Your Code
end)

I’ve never messed around with making my own plugin but it sounds cool, good luck.