I need opinion for my script!

ALL ORGANISATION


MODULE(NOT ADDED IN MY SCRIPT) GuiObjectModule

local module = {}

local guiObjectInstance = {
	{
		class = "ScreenGui",
		id = 18195363547,
	},
	
	{
		class = "Frame",
		id = 18195371351,
	},
	
	{
		class = "ScrollingFrame",
		id = 18195432008,
	},
	
	{
		class = "Folder",
		id = 18195374549,
	},
	
	{
		class = "TextButton",
		id = 18195384998,
	},
	
	{
		class = "TextLabel",
		id = 18195407069,
	},
	
	{
		class = "ImageLabel",
		id = 18195413206,
	},
}

function module.getThumbnail(id: number, size: {x: number, y: number})
	return "rbxthumb://type=Asset&id=".. id ..{`&w={size.x}&h={size.y}`}
end

return module

{
class = "Folder",
id = 18195374549,
},

{
class = "TextButton",
id = 18195384998,
},

{
class = "TextLabel",
id = 18195407069,
},

{
class = "ImageLabel",
id = 18195413206,
},
}

function module.getThumbnail(id: number, size: {x: number, y: number})
return "rbxthumb://type=Asset&id=".. id ..{`&w={size.x}&h={size.y}`}
end

return module

MY LOCAL SCRIPT

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

local PropertyModule = require(script.PropertyModule)

local Template = script.Template

local container = script.Parent.Parent
local uiGeneratorFrame = container.UIGenerator
local choiceFrame = uiGeneratorFrame.ChoiceFrame
local propertyFrame = uiGeneratorFrame.PropertyFrame
local choiceButton = uiGeneratorFrame.ChoiceButton

local scrollingFrame = choiceFrame:FindFirstChild("ScrollingFrame")
local scrollingPropertyFrame = propertyFrame:FindFirstChild("ScrollingPropertyFrame")
local searchBox = choiceFrame:FindFirstChild("Searchbox")

local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui

local InstancesTable = {
	"ScreenGui",
	"Frame",
	"Folder",
	"TextButton",
	"TextLabel",
	"ImageLabel",
}

local function updatePlaceHolder(textbox: TextBox, newText: string)
	textbox.PlaceholderText = newText
end

local function addPropertyToScrollingProperty(a: Instance, propertyName: string, value: any)
	local propertyBox = Template.PropertyBox:Clone()
	
	propertyBox.Name = propertyName
	propertyBox.PlaceholderText = propertyName..": "..tostring(value)
	
	propertyBox.Parent = scrollingPropertyFrame
	
	propertyBox.FocusLost:Connect(function()
		local str = propertyBox.Text
		
		if not str:match("^%s+") and str ~= "" then
			local bool, t = PropertyModule:SetProperty(a, {[propertyBox.Name] = propertyBox.Text})

			if bool then
				updatePlaceHolder(propertyBox, t.Name..": "..tostring(t.Value))
			end
		end
	end)
end

local function setDefaultProperty(a: Instance)
	local t = PropertyModule:GetProperty(a)
	
	for _, v in scrollingPropertyFrame:GetChildren() do
		if v:IsA("TextBox") then
			v:Destroy()
		end
	end

	task.wait(0.5)

	for propertyName, value in t do
		a[propertyName] = value

		addPropertyToScrollingProperty(a, propertyName, value)
	end
end

local function setButtonClasses(frame: Frame, a: any)
	local classButton = Template.ClassButton:Clone()
		
	classButton.Text = a
	classButton.Name = a.."Button"
	classButton.Parent = frame
	
	classButton.MouseButton1Click:Connect(function()
		if #playerGui:GetDescendants() > 350 then
			return error("Tu as depasser les limites d'ui maximum veuillez en suprimer")
		else
			local newInstance = Instance.new(a):: Instance

			setDefaultProperty(newInstance)
		end
	end)
end

local function updateText()
	for _, v in scrollingFrame:GetChildren() do
		if v:IsA("TextButton") then
			local match = string.match(v.Text:lower(), "^"..searchBox.Text:lower())
			
			if not match then
				v.Visible = false
			else
				v.Visible = true
			end
		end
	end
end

for _, v in InstancesTable do
	if not scrollingFrame:FindFirstChild(v.."Button") then
		setButtonClasses(scrollingFrame, v)
	end
end

choiceButton.MouseButton1Click:Connect(function()
	choiceFrame.Visible = not choiceFrame.Visible
end)

searchBox:GetPropertyChangedSignal("Text"):Connect(updateText)

MY MODULE(added in my script) PropertyModule

local player = game.Players.LocalPlayer
local playerGui = player.PlayerGui

local module = {}

local guiObjectTable = {
	
	ScreenGui = {
		Name = "NoNameGui",
		
		Enabled = false,
		Parent = playerGui,
	},
	
	Frame = {
		Name = "NoNameFrame",

		BackgroundColor3 = Color3.new(255, 255, 255),
		Transparency = 0,
		
		Position = UDim2.new(0.5, 0, 0.5, 0),
		Size = UDim2.new(0.2, 0, 0.2, 0),

		Visible = false,
		Parent = playerGui
	},
	
	TextLabel = {
		Name = "NoNameText",
		Text = "NoText",

		BackgroundColor3 = Color3.new(255, 255, 255),
		TextColor3 = Color3.new(0, 0, 0),
		Transparency = 0,
		
		Position = UDim2.new(0.5, 0, 0.5, 0),
		Size = UDim2.new(0.2, 0, 0.2, 0),

		Visible = false,
		Parent = playerGui
	},
	
	TextButton = {
		Name = "NoNameText",
		Text = "NoText",

		BackgroundColor3 = Color3.new(255, 255, 255),
		TextColor3 = Color3.new(0, 0, 0),
		Transparency = 0,
		
		Position = UDim2.new(0.5, 0, 0.5, 0),
		Size = UDim2.new(0.2, 0, 0.2, 0),

		Visible = false,
		Parent = playerGui
	},
	
	Folder = {
		Name = "NoNameFolder",
		
		Parent = playerGui
	},
	
	
	ImageLabel = {
		Name = "NoNameImage",
		Image = "",
		
		Position = UDim2.new(0.5, 0, 0.5, 0),
		Size = UDim2.new(0.2, 0, 0.2, 0),
		Transparency = 0,
		
		BackgroundColor3 = Color3.new(255, 255, 255),
		ImageColor3 = Color3.new(255, 255, 255),
		
		Parent = playerGui
	}
}

function module:GetProperty(a: GuiObject)
	local property = guiObjectTable[a.ClassName]
	
	return property
end

function module:SetProperty(a: GuiObject, property: any)
	local b
	
	if typeof(property) == "table" then
		for i, v in property do
			if i == "Parent" then
				
				for _, gui in playerGui:GetDescendants() do
					if gui.Name:lower() == v:lower() then
						
						b = gui
						
					elseif playerGui.Name:lower() == v:lower() then
						
						if a.Parent ~= a.Parent then
							b = playerGui
						else
							return
						end
					end
				end
				
			elseif i == "Position" or i == "Size" then
				
				b = UDim2.new(v)
			elseif i == "BackgroundColor3" or i == "ImageColor3" or i == "TextColor3" then
				
				b = Color3.new(v)
				
			elseif i == "Visible" or i == "Enabled" then
				
				if v:lower() == "true" then
					b = true
				elseif v:lower() == "false" then
					b = false
				else
					b = false
				end
			else
			
				b = v:lower()
			end
			
			a[i] = b
			
			return true, {Name = i, Value = b}
		end
	end
end

return module
2 Likes

how did you get that ui for the services like replicated storage btw

You mean the icons image? ^^^^^^

Yeah he means that thing
charrrrs