Cant figure out how to add custom themes

So Im trying to add custom themes to this gui lib for a small, personal admin panel I’m making and I cannot seem to figure out why the custom themes will not be imported from the other module script to my main theme dictionary.

It will just return “Attempting to index nil with main_container at {where ever your trying to apply the colour you want}”

Theme module script:

Custom = {}

Custom.CustomThemes = {

	["Example"] = {

		main_container = Color3.fromRGB(38, 38, 213),
		separator_color = Color3.fromRGB(63, 63, 65),

		text_color = Color3.fromRGB(206, 206, 206),

		category_button_background = Color3.fromRGB(63, 62, 65),
		category_button_border = Color3.fromRGB(72, 71, 74),

		checkbox_checked = Color3.fromRGB(132, 255, 130),
		checkbox_outer = Color3.fromRGB(84, 81, 86),
		checkbox_inner = Color3.fromRGB(132, 132, 136),

		slider_color = Color3.fromRGB(177, 177, 177),
		slider_color_sliding = Color3.fromRGB(132, 255, 130),
		slider_background = Color3.fromRGB(88, 84, 90),
		slider_text = Color3.fromRGB(177, 177, 177),

		textbox_background = Color3.fromRGB(103, 103, 106),
		textbox_background_hover = Color3.fromRGB(137, 137, 141),
		textbox_text = Color3.fromRGB(195, 195, 195),
		textbox_text_hover = Color3.fromRGB(232, 232, 232),
		textbox_placeholder = Color3.fromRGB(135, 135, 138),

		dropdown_background = Color3.fromRGB(88, 88, 91),
		dropdown_text = Color3.fromRGB(195, 195, 195),
		dropdown_text_hover = Color3.fromRGB(232, 232, 232),
		dropdown_scrollbar_color = Color3.fromRGB(118, 118, 121),

		button_background = Color3.fromRGB(103, 103, 106),
		button_background_hover = Color3.fromRGB(137, 137, 141),
		button_background_down = Color3.fromRGB(70, 70, 81),

		scrollbar_color = Color3.fromRGB(118, 118, 121),

		notification_warn = Color3.fromRGB(236, 129, 44),
		notification_success = Color3.fromRGB(139, 217, 45),
		notification_info = Color3.fromRGB(206, 206, 206),

		NotifSound_1 = "",
		NotifSound_2 = ""

	} -- add your custom theme stuff inside here

}

return Custom 

Importer/Theme storage:

function Admin.ImportCustomThemes()
	local CustomthemeScript = require("Customthemes")

	local themes = CustomthemeScript.CustomThemes

	table.insert(Admin.themes, themes) -- store the theme here for later use.

	for i, v in pairs(Admin.themes) do
		print(i)
		--[[print(v)
		for w, e in themes do
			print(w, e)
		end]]
	end
end
Admin.themes = {

	["Dark"] = {

		main_container = Color3.fromRGB(32, 32, 33),
		separator_color = Color3.fromRGB(63, 63, 65),

		text_color = Color3.fromRGB(206, 206, 206),

		category_button_background = Color3.fromRGB(63, 62, 65),
		category_button_border = Color3.fromRGB(72, 71, 74),

		checkbox_checked = Color3.fromRGB(132, 255, 130),
		checkbox_outer = Color3.fromRGB(84, 81, 86),
		checkbox_inner = Color3.fromRGB(132, 132, 136),

		slider_color = Color3.fromRGB(177, 177, 177),
		slider_color_sliding = Color3.fromRGB(132, 255, 130),
		slider_background = Color3.fromRGB(88, 84, 90),
		slider_text = Color3.fromRGB(177, 177, 177),

		textbox_background = Color3.fromRGB(103, 103, 106),
		textbox_background_hover = Color3.fromRGB(137, 137, 141),
		textbox_text = Color3.fromRGB(195, 195, 195),
		textbox_text_hover = Color3.fromRGB(232, 232, 232),
		textbox_placeholder = Color3.fromRGB(135, 135, 138),

		dropdown_background = Color3.fromRGB(88, 88, 91),
		dropdown_text = Color3.fromRGB(195, 195, 195),
		dropdown_text_hover = Color3.fromRGB(232, 232, 232),
		dropdown_scrollbar_color = Color3.fromRGB(118, 118, 121),

		button_background = Color3.fromRGB(103, 103, 106),
		button_background_hover = Color3.fromRGB(137, 137, 141),
		button_background_down = Color3.fromRGB(70, 70, 81),

		scrollbar_color = Color3.fromRGB(118, 118, 121),

		notification_warn = Color3.fromRGB(236, 129, 44),
		notification_success = Color3.fromRGB(139, 217, 45),
		notification_info = Color3.fromRGB(206, 206, 206),

		NotifSound_1 = "",
		NotifSound_2 = ""

	},

	["Light"] = {

		main_container = Color3.fromRGB(249, 249, 255),
		separator_color = Color3.fromRGB(223, 219, 228),

		text_color = Color3.fromRGB(96, 96, 96),

		category_button_background = Color3.fromRGB(223, 219, 228),
		category_button_border = Color3.fromRGB(200, 196, 204),

		checkbox_checked = Color3.fromRGB(114, 214, 112),
		checkbox_outer = Color3.fromRGB(198, 189, 202),
		checkbox_inner = Color3.fromRGB(249, 239, 255),

		slider_color = Color3.fromRGB(114, 214, 112),
		slider_color_sliding = Color3.fromRGB(114, 214, 112),
		slider_background = Color3.fromRGB(198, 188, 202),
		slider_text = Color3.fromRGB(112, 112, 112),

		textbox_background = Color3.fromRGB(198, 189, 202),
		textbox_background_hover = Color3.fromRGB(215, 206, 227),
		textbox_text = Color3.fromRGB(112, 112, 112),
		textbox_text_hover = Color3.fromRGB(50, 50, 50),
		textbox_placeholder = Color3.fromRGB(178, 178, 178),

		dropdown_background = Color3.fromRGB(198, 189, 202),
		dropdown_text = Color3.fromRGB(112, 112, 112),
		dropdown_text_hover = Color3.fromRGB(50, 50, 50),
		dropdown_scrollbar_color = Color3.fromRGB(198, 189, 202),

		button_background = Color3.fromRGB(198, 189, 202),
		button_background_hover = Color3.fromRGB(215, 206, 227),
		button_background_down = Color3.fromRGB(178, 169, 182),

		scrollbar_color = Color3.fromRGB(198, 189, 202),

		notification_warn = Color3.fromRGB(236, 129, 44),
		notification_success = Color3.fromRGB(139, 217, 45),
		notification_info = Color3.fromRGB(206, 206, 206),

		NotifSound_1 = "",
		NotifSound_2 = ""

	}
}

Instead of doing:

table.insert(Admin.themes, themes)

Try:

for theme_name, theme_data in pairs(themes) do
	Admin.themes[theme_name] = theme_data
end

Explanation:
It seems your previous approach was just putting the whole custom theme table into the main one instead of an individual item of it.

Hope this helps!

I tried doing individuals too but the same result too. Ill give this ago, thanks.

TYSM, I put this off for a month and had a break as I spent 3 days trying to fix it… Thanks so much!!! :heart::heart:

1 Like