Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Dock Widget Not Enabling On Plugin Button Click?

Asked by
DollorLua 235 Moderation Voter
4 years ago

i currently have this script here:

local Name = "Terrain Generator"
local toolBar = plugin:CreateToolbar("Dollor's Plugins")
local Text = "Generate Terrain"
local ToolTip = "Click this button, set the prefrences to what you like, then click generate."
local Button = toolBar:CreateButton(Name, ToolTip, "rbxassetid://413372167", Text)

local widgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float,true,false,200,300,150,150)

local testWidget = plugin:CreateDockWidgetPluginGui("TerrainGenerator", widgetInfo)
testWidget.Title = "Terrain Generator"
testWidget.Enabled = false
local function syncGuiColors(objects)
    local function setColors()
        for _, guiObject in pairs(objects) do
            guiObject.BackgroundColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainBackground)
            guiObject.TextColor3 = settings().Studio.Theme:GetColor(Enum.StudioStyleGuideColor.MainText)
        end
    end
    setColors()
    settings().Studio.ThemeChanged:Connect(setColors)
end

Button.Click:Connect(function()
    if testWidget.Enabled == false then
        testWidget.Enabled = true
    else
        testWidget.Enabled = false
    end
end)

but whenever i click the UI Button it doesn't open the DockWidget, is there any better way of enabling the DockWidget?

Answer this question