example:
local ImGui = game:GetService("ImGuiService")
local window_active = Instance.new("BoolValue")
window_active.Value = true
local render_connection
render_connection = ImGui.Render:Connect(function()
if ImGui.Begin("Lua Window", window_active) then
ImGui.Text(("Hello, %s"):format("world!"))
if ImGui.Button("Destroy") then
window_active.Value = false
end
end
ImGui.End()
-- disconnecting the connection should go after the button press because
-- we don't want to omit the above End midway through
if not window_active.Value then render_connection:Disconnect() end
end)
example: