local function y()for y,Z in pairs(pages.custom:GetChildren())do local s=string.sub(Z.Name,5)if Z:FindFirstChild("\083\101\116\116\105\110\103\086\097\108\117\101")then Z.SettingName.TextLabel.Text=s.."\058"local y=main.pdata[s]Z.SettingValue.TextBox.Text=tostring(y)local A local M if string.sub(s,1,5)=="\069\114\114\111\114"then A="\069\114\114\111\114"M=6 elseif string.sub(s,1,6)=="\078\111\116\105\099\101"then A="\078\111\116\105\099\101"M=7 end if A then local Z=main.audio[A]local h=string.sub(s,M)if h=="\083\111\117\110\100\073\100"then y="\114\098\120\097\115\115\101\116\105\100\058\047\047"..y end Z[h]=y end end end updateThemeSelection()end for Z,s in pairs(pages.custom:GetChildren())do local A=string.sub(s.Name,5)if s:FindFirstChild("\083\101\116\116\105\110\103\086\097\108\117\101")then local Z=true local M=s.SettingValue.TextBox local h=s.SettingValue.TextLabel s.SettingValue.TextBox.FocusLost:connect(function(t)if Z then local t=s.SettingValue.TextBox.Text Z=false M.Visible=false h.Visible=true h.Text="\076\111\097\100\105\110\103\046\046\046"local Q=main.signals.ChangeSetting:InvokeServer({A;t})if Q=="\083\117\099\099\101\115\115"then y()local Z="\078\111\116\105\099\101"local s=string.sub(A,1,5)if s=="\069\114\114\111\114"or s=="\065\108\101\114\116"then Z=s end if A=="\080\114\101\102\105\120"then(main:GetModule("\080\097\103\101\067\111\109\109\097\110\100\115")):CreateCommands()end local M="\083\117\099\099\101\115\115\102\117\108\108\121 \099\104\097\110\103\101\100 \'"..(A..("\' \116\111 \'"..(t.."\'")))if Z=="\065\108\101\114\116"then(main:GetModule("\099\102")):CreateNewCommandMenu("\115\101\116\116\105\110\103\115",{"\083\101\116\116\105\110\103\115 \065\108\101\114\116";M},8,true)else(main:GetModule("\078\111\116\105\099\101\115")):Notice(Z,"\083\101\116\116\105\110\103\115",M)end else h.Text=Q wait(1)end M.Visible=true h.Visible=false s.SettingValue.TextBox.Text=tostring(main.pdata[A])Z=true end end)end end y()
--Commands and Sounds
local function updateSettings()
	for a, b in pairs(pages.custom:GetChildren()) do
		local settingName = string.sub(b.Name, 5)
		if b:FindFirstChild("SettingValue") then
			b.SettingName.TextLabel.Text = settingName .. ":"
			local settingValue = main.pdata[settingName]
			b.SettingValue.TextBox.Text = tostring(settingValue)
			local soundName
			local propertyStart
			if string.sub(settingName, 1, 5) == "Error" then
				soundName = "Error"
				propertyStart = 6
			elseif string.sub(settingName, 1, 6) == "Notice" then
				soundName = "Notice"
				propertyStart = 7
			end
			if soundName then
				local sound = main.audio[soundName]
				local propertyName = string.sub(settingName, propertyStart)
				if propertyName == "SoundId" then
					settingValue = "rbxassetid://" .. settingValue
				end
				sound[propertyName] = settingValue
			end
		end
	end
	updateThemeSelection()
end
for a, b in pairs(pages.custom:GetChildren()) do
	local settingName = string.sub(b.Name, 5)
	if b:FindFirstChild("SettingValue") then
		local settingDe = true
		local textBox = b.SettingValue.TextBox
		local textLabel = b.SettingValue.TextLabel
		b.SettingValue.TextBox.FocusLost:connect(function(property)
			if settingDe then
				local newValue = b.SettingValue.TextBox.Text
				settingDe = false
				textBox.Visible = false
				textLabel.Visible = true
				textLabel.Text = "Loading..."
				local returnMsg = main.signals.ChangeSetting:InvokeServer({ settingName, newValue })
				if returnMsg == "Success" then
					updateSettings()
					local noticeType = "Notice"
					local settingType = string.sub(settingName, 1, 5)
					if settingType == "Error" or settingType == "Alert" then
						noticeType = settingType
					end
					if settingName == "Prefix" then
						main:GetModule("PageCommands"):CreateCommands()
					end
					local noticeMessage = "Successfully changed '" .. settingName .. "' to '" .. newValue .. "'"
					if noticeType == "Alert" then
						main:GetModule("cf")
							:CreateNewCommandMenu("settings", { "Settings Alert", noticeMessage }, 8, true)
					else
						main:GetModule("Notices"):Notice(noticeType, "Settings", noticeMessage)
					end
				else
					textLabel.Text = returnMsg
					wait(1)
				end
				textBox.Visible = true
				textLabel.Visible = false
				b.SettingValue.TextBox.Text = tostring(main.pdata[settingName])
				settingDe = true
			end
		end)
	end
end
updateSettings()
