Gui to Lua ~ Convert GUI's and (most) Models into Lua, React or Fusion (Supports Path2D!)

Gui to Lua

This plugin allows you to convert GUI’s and most models to Lua script, in just a few clicks!


UPDATE (September 18, 2023)

Plugin got a full rewrite, it is now much faster.

November 30, 2023

Plugin no longer splits large outputs.

before:

after:


Why this plugin is good

This plugin will:
  • Work forever because it uses uses roblox studio’s api dump (2023-02-08T00:00:00Z)
  • Convert every accessible property
  • Convert attributes
  • Let you convert objects into regular Lua, Roact and Fusion 1*
  • Let you convert instances of practically unlimited sizes
  • Let you generate different types of outputs
  • Recieve updates when needed
  • Support undo (lol)

1* Scripts, LocalScripts and ModuleScripts will not be converted when using Roact or Fusion.


A few examples of the different types of outputs:

Legacy

--[[
	
	Gui2Lua Winning! ~ Ch0nky Code:tm:
	
	6 instances
	
]]--

local tbl = 
{
	ScreenGui = Instance.new("ScreenGui"),
	Frame = Instance.new("Frame"),
	ImageLabel = Instance.new("ImageLabel"),
	src = Instance.new("LocalScript"),
	m1 = Instance.new("ModuleScript"),
	m2 = Instance.new("ModuleScript"),
}

tbl.ScreenGui.Enabled = false
tbl.ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
tbl.ScreenGui.Parent = game:GetService("StarterGui")

tbl.Frame.Size = UDim2.new(0, 100, 0, 100)
tbl.Frame.Position = UDim2.new(0.459109, 0, 0.418301, 0)
tbl.Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
tbl.Frame.Parent = tbl.ScreenGui

tbl.ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
tbl.ImageLabel.Image = "rbxasset://studio_svg_textures/Shared/WidgetIcons/Light/Large/CommandBar@3x.png"
tbl.ImageLabel.Size = UDim2.new(0, 100, 0, 100)
tbl.ImageLabel.Parent = tbl.Frame

tbl.src.Name = "src"
tbl.src.Parent = tbl.ScreenGui

tbl.m1.Name = "m1"
tbl.m1.Parent = tbl.src

tbl.m2.Name = "m2"
tbl.m2.Parent = tbl.src

local modules, cache = {}, {}

modules[tbl.m1] = function()
	local module = {}
	
	module.str = "hello from M1"
	
	module.p = print
	
	return module
end

modules[tbl.m2] = function()
	local module = {}
	
	module.str = "hello from M2"
	
	module.p = function(str)
		print(str .. " yuhh")
	end
	
	return module
end

local o_require = require;
local function require(module)
	local real, cached = modules[module], cache[module]
	
	if cached then return cached end
	
	if not real then return o_require(module) end
	
	cache[module] = real()
	
	return cache[module]
end

task.spawn(function()
	 local script = tbl.src

	local m1, m2 = require(script.m1), require(script.m2)
	
	m1.p(require(script.m1) == require(script.m1), m1.str, m1.p == m2.p)
	
	-- > true hello from M1 false
end)
Outputs

Compact

--[[
	
	Gui2Lua Winning! ~ Ch0nky Code:tm:
	
	6 instances
	
]]--

local tbl = 
{
	ScreenGui = Instance.new("ScreenGui"),
	Frame = Instance.new("Frame"),
	ImageLabel = Instance.new("ImageLabel"),
	src = Instance.new("LocalScript"),
	m1 = Instance.new("ModuleScript"),
	m2 = Instance.new("ModuleScript"),
}

tbl.ScreenGui.Enabled = false; tbl.ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling; tbl.ScreenGui.Parent = game:GetService("StarterGui"); 
tbl.Frame.Size = UDim2.new(0, 100, 0, 100); tbl.Frame.Position = UDim2.new(0.459109, 0, 0.418301, 0); tbl.Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255); tbl.Frame.Parent = tbl.ScreenGui; 
tbl.ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255); tbl.ImageLabel.Image = "rbxasset://studio_svg_textures/Shared/WidgetIcons/Light/Large/CommandBar@3x.png"; tbl.ImageLabel.Size = UDim2.new(0, 100, 0, 100); tbl.ImageLabel.Parent = tbl.Frame; 
tbl.src.Name = "src"; tbl.src.Parent = tbl.ScreenGui; 
tbl.m1.Name = "m1"; tbl.m1.Parent = tbl.src; 
tbl.m2.Name = "m2"; tbl.m2.Parent = tbl.src; 

local modules, cache = {}, {}

modules[tbl.m1] = function()
	local module = {}
	
	module.str = "hello from M1"
	
	module.p = print
	
	return module
end

modules[tbl.m2] = function()
	local module = {}
	
	module.str = "hello from M2"
	
	module.p = function(str)
		print(str .. " yuhh")
	end
	
	return module
end

local o_require = require;
local function require(module)
	local real, cached = modules[module], cache[module]
	
	if cached then return cached end
	
	if not real then return o_require(module) end
	
	cache[module] = real()
	
	return cache[module]
end

task.spawn(function()
	 local script = tbl.src

	local m1, m2 = require(script.m1), require(script.m2)
	
	m1.p(require(script.m1) == require(script.m1), m1.str, m1.p == m2.p)
	
	-- > true hello from M1 false
end)

Compact Fusion

--[[
	
	Gui2Lua Winning! ~ Ch0nky Code:tm:
	
	7 instances
	
]]--

local Fusion = {};
local New, Children = Fusion.New, Fusion.Children; -- you can change this local's name in the variable name field, format: "new_function_name;child_name"

local ScreenGui = New "ScreenGui" { Enabled = false, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, 
	[Children] = {
		Frame = New "Frame" { Size = UDim2.new(0, 100, 0, 100), Position = UDim2.new(0.459109, 0, 0.418301, 0), BackgroundColor3 = Color3.fromRGB(255, 255, 255), 
			[Children] = {
				ImageLabel = New "ImageLabel" { BackgroundColor3 = Color3.fromRGB(255, 255, 255), Image = "rbxasset://studio_svg_textures/Shared/WidgetIcons/Light/Large/CommandBar@3x.png", Size = UDim2.new(0, 100, 0, 100), },
			}
		},
		src = New "LocalScript" { Name = "src", 
			[Children] = {
				m1 = New "ModuleScript" { Name = "m1", },
				m2 = New "ModuleScript" { Name = "m2", },
			}
		},
		TextButton = New "TextButton" { AutoButtonColor = false, BackgroundColor3 = Color3.fromRGB(255, 255, 255), FontFace = Font.new("rbxasset://fonts/families/SourceSansPro.json", Enum.FontWeight.Regular, Enum.FontStyle.Normal), TextColor3 = Color3.fromRGB(0, 0, 0), Position = UDim2.new(0.226295, 0, 0.4947, 0), TextSize = 14, Size = UDim2.new(0, 200, 0, 50), Active = false, },
	}
}

Supercompact

Which is basically minified.
--[[
	
	Gui2Lua Winning! ~ Ch0nky Code:tm:
	
	6 instances
	
]]--

local tbl = { ScreenGui = Instance.new("ScreenGui"); Frame = Instance.new("Frame"); ImageLabel = Instance.new("ImageLabel"); src = Instance.new("LocalScript"); m1 = Instance.new("ModuleScript"); m2 = Instance.new("ModuleScript"); }

tbl.ScreenGui.Enabled = false; tbl.ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling; tbl.ScreenGui.Parent = game:GetService("StarterGui"); tbl.Frame.Size = UDim2.new(0, 100, 0, 100); tbl.Frame.Position = UDim2.new(0.459109, 0, 0.418301, 0); tbl.Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255); tbl.Frame.Parent = tbl.ScreenGui; tbl.ImageLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255); tbl.ImageLabel.Image = "rbxasset://studio_svg_textures/Shared/WidgetIcons/Light/Large/CommandBar@3x.png"; tbl.ImageLabel.Size = UDim2.new(0, 100, 0, 100); tbl.ImageLabel.Parent = tbl.Frame; tbl.src.Name = "src"; tbl.src.Parent = tbl.ScreenGui; tbl.m1.Name = "m1"; tbl.m1.Parent = tbl.src; tbl.m2.Name = "m2"; tbl.m2.Parent = tbl.src; 

local modules, cache = {}, {}

modules[tbl.m1] = function()
	local module = {}
	
	module.str = "hello from M1"
	
	module.p = print
	
	return module
end

modules[tbl.m2] = function()
	local module = {}
	
	module.str = "hello from M2"
	
	module.p = function(str)
		print(str .. " yuhh")
	end
	
	return module
end

local o_require = require;
local function require(module)
	local real, cached = modules[module], cache[module]
	
	if cached then return cached end
	
	if not real then return o_require(module) end
	
	cache[module] = real()
	
	return cache[module]
end

task.spawn(function()
	 local script = tbl.src

	local m1, m2 = require(script.m1), require(script.m2)
	
	m1.p(require(script.m1) == require(script.m1), m1.str, m1.p == m2.p)
	
	-- > true hello from M1 false
end)

All three output formats have their own legacy, compact and supercompact output.


Preview

image




Issues

If you have any issues with the plugin, please report them on this thread so that i can fix them ASAP.

shout out to this guy (literally saved me wow)
this is my first thread


Gui to Lua


Enjoy!

6 Likes

That’s a nice plugin, many usage cases. The only thing I cant understand is why its called GUI to Lua?

2 Likes

The true purpose of the plugin is unclear to me. What purpose does it serve?

I think the more important question is: What problem does it solve?

I mean, it converts GUIs to scripts, sure. But what issue does it fix?

It would’ve been nicer if it converted GUIs to functions instead. That way, you could call it from the rest of your code and it would create that GUI element. Or, it could utilize another library such as Fusion or Roact to make code size smaller and make it more useful.

1 Like

Its called Gui to Lua because the main purpose of it is to convert GUI’s into script. The way that it was made allows it to process models aswell but is not guaranteed to work (stuff being not creatable, stuff inside non creatable instances, the kind of stuff that never really happens in gui’s)


The problem that this solves is when you need to create an instance from code. For example when you need to make a UI library or something of that sort. I do agree that the use case is pretty niche but when you do need it it’s really nice to have something that does it for you.


You can use the output of the plugin to create the functions that you need in your code, worst case scenario you could literally paste the output of the plugin into a function and use it.


I will look into adding support for those libraries.

But wouldn’t most people use Fusion or Roact for that?

1 Like

Roact and Fusion create the ui, this plugin writes the code that creates the ui. (Roact and Fusion support soon)

1 Like

that’s not something I’d necessarily use but cool concept

1 Like