function module.SetupTextbox(y,U,C)local function L(U,y,L,v)if string.sub(string.lower(v),1,#y)==y then table.insert(U,{Name=v;ArgPos=L})if#U==C.maxSuggestions then return true end end end local v=C.specificArg currentProps[U]=C createSuggestionLabels(C)setupEnterPress(C)local e C.textBox.Changed:connect(function(U)if U=="\084\101\120\116"then local U=-1 local y local P={}if v then U=1 table.insert(P,C.textBox.Text)else C.textBox.Text:gsub("\040\091\094"..(main.pdata.SplitKey.."\093\043\041"),function(C)U=U+1 if U==0 then y=C elseif U>0 then table.insert(P,C)end end)if U>0 and not C.currentBarCommand then local U=string.sub(y,1,1)if U==main.settings.UniversalPrefix or U==main.pdata.Prefix then y=string.sub(y,2)end y=string.lower(y)for U,L in pairs(main.commandInfo)do local v=string.lower(L.Name)if v==y then C.currentBarCommand=L elseif L.Aliases then for U,v in pairs(L.Aliases)do if string.lower(v)==y then C.currentBarCommand=L end end end end elseif U<=0 then C.currentBarCommand=nil end end local i={}C.suggestionPos=1 if#C.textBox.Text>1 or v and#C.textBox.Text>0 then if U==0 then local U=string.lower(string.sub(C.textBox.Text,2))local y=string.lower(string.sub(C.textBox.Text,1,1))for L,v in pairs(main.commandInfo)do local e=string.lower(v.Name)local P=v.Prefixes[1]if string.sub(e,1,#U)==U and P==y then table.insert(i,{Name=v.Name,Args=v.Args,Prefixes=v.Prefixes,ArgPos=0})if#i==C.maxSuggestions then break end end local p=v.UnFunction if p then if string.sub(string.lower(p),1,#U)==U and P==y then table.insert(i,{Name=p;Args={};Prefixes=v.Prefixes;ArgPos=0})if#i==C.maxSuggestions then break end end end end elseif C.currentBarCommand or v then local y if v then y=v else y=C.currentBarCommand.Args[U]end local e={}local p=string.lower(P[U])local X=string.sub(C.textBox.Text,-1)if X~=" "and X~=main.pdata.SplitKey then if y=="\112\108\097\121\101\114"or y=="\112\108\097\121\101\114\097\114\103"then for C,y in pairs(main.qualifiers)do if L(i,p,U,y)then break end end if#i<C.maxSuggestions then for C,y in pairs(main.players:GetChildren())do if L(i,p,U,y.Name)then break end end end elseif y=="\099\111\108\111\117\114"or y=="\099\111\108\111\114"or y=="\099\111\108\111\114\051"then for C,y in pairs(main.colors)do if L(i,p,U,y)then break end end elseif y=="\109\097\116\101\114\105\097\108"then for C,y in pairs(main.materials)do if L(i,p,U,y)then break end end elseif y=="\114\097\110\107"then for C,y in pairs(main.settings.Ranks)do if L(i,p,U,y[2])then break end end elseif y=="\116\101\097\109"or y=="\116\101\097\109\099\111\108\111\114"then for C,y in pairs(main.teams:GetChildren())do if L(i,p,U,y.Name)then break end end elseif y=="\109\111\114\112\104"then for C,y in pairs(main.morphNames)do if L(i,p,U,C)then break end end elseif y=="\116\111\111\108\115"or y=="\103\101\097\114\115"or y=="\116\111\111\108"or y=="\103\101\097\114"then for C,y in pairs(main.toolNames)do if L(i,p,U,C)then break end end end end end end C.suggestionDisplayed=#i if C.currentBarCommand and(#C.currentBarCommand.Args==U and C.suggestionDisplayed>0)then forceExecute=true else forceExecute=false end for U=1,C.maxSuggestions,1 do local y=i[U]local L=C.rframe["\076\097\098\101\108"..U]if y then local v=false if y.Args then v=true end local P=false if v and y.Prefixes[1]==main.settings.UniversalPrefix then P=true end local i={}if v then for U,C in pairs(y.Args)do if not P or C~="\112\108\097\121\101\114"or C=="\112\108\097\121\101\114\097\114\103"then table.insert(i,"\060"..(C.."\062"))end end end L.TextLabel.Text=y.Name..(" "..table.concat(i," "))if U==C.suggestionPos then L.BackgroundColor3=C.highlightColor else L.BackgroundColor3=C.otherColor end C.suggestionLabels["\076\097\098\101\108"..U]=y if C.mainParent.Name~="\067\109\100\066\097\114"then local y=C.rframe.LabelTemplate.AbsoluteSize.Y local L=y*U local v=C.rframe.AbsolutePosition.Y+L local P=main.gui.Notices.AbsoluteSize.Y if v+5>P then if not e then e=C.mainParent.Position end C.mainParent.Position=C.mainParent.Position-UDim2.new(0,0,0,y)end end L.Visible=true else L.Visible=false end end if e and#i<1 then C.mainParent.Position=e e=nil end if#i<1 and C.mainParent.Name~="\067\109\100\066\097\114"then C.mainParent.ClipsDescendants=true else C.mainParent.ClipsDescendants=false end end end)end module:SetupTextbox("\099\109\100\098\097\114\049",mainProps)
--Search Bar suggestions
function module:SetupTextbox(commandName, props)
	local function collectArguments(suggestions, currentBarArg, totalArgs, argName)
		if string.sub(string.lower(argName), 1, #currentBarArg) == currentBarArg then
			table.insert(suggestions, { Name = argName, ArgPos = totalArgs })
			if #suggestions == props.maxSuggestions then
				return true
			end
		end
	end
	local specificArg = props.specificArg
	currentProps[commandName] = props
	createSuggestionLabels(props)
	setupEnterPress(props)
	local originalPosition
	props.textBox.Changed:connect(function(property)
		if property == "Text" then
			local totalArgs = -1
			local barCommandName
			local args = {}
			if specificArg then
				totalArgs = 1
				table.insert(args, props.textBox.Text)
			else
				props.textBox.Text:gsub("([^" .. main.pdata.SplitKey .. "]+)", function(c)
					totalArgs = totalArgs + 1
					if totalArgs == 0 then
						barCommandName = c
					elseif totalArgs > 0 then
						table.insert(args, c)
					end
				end)
				if totalArgs > 0 and not props.currentBarCommand then
					local firstChar = string.sub(barCommandName, 1, 1)
					if firstChar == main.settings.UniversalPrefix or firstChar == main.pdata.Prefix then
						barCommandName = string.sub(barCommandName, 2)
					end
					barCommandName = string.lower(barCommandName)
					--
					for _, command in pairs(main.commandInfo) do
						local cName = string.lower(command.Name)
						if cName == barCommandName then
							props.currentBarCommand = command
						elseif command.Aliases then
							for i, v in pairs(command.Aliases) do
								if string.lower(v) == barCommandName then
									props.currentBarCommand = command
								end
							end
						end
					end
					--
				elseif totalArgs <= 0 then
					props.currentBarCommand = nil
				end
			end
			local suggestions = {}
			props.suggestionPos = 1
			if #props.textBox.Text > 1 or (specificArg and #props.textBox.Text > 0) then
				if totalArgs == 0 then
					local barInput = string.lower(string.sub(props.textBox.Text, 2))
					local barPrefix = string.lower(string.sub(props.textBox.Text, 1, 1))
					for _, command in pairs(main.commandInfo) do
						local cName = string.lower(command.Name)
						local cPrefix = command.Prefixes[1]
						if string.sub(cName, 1, #barInput) == barInput and cPrefix == barPrefix then
							table.insert(
								suggestions,
								{ Name = command.Name, Args = command.Args, Prefixes = command.Prefixes, ArgPos = 0 }
							)
							if #suggestions == props.maxSuggestions then
								break
							end
						end
						local unName = command.UnFunction
						if unName then
							if string.sub(string.lower(unName), 1, #barInput) == barInput and cPrefix == barPrefix then
								table.insert(
									suggestions,
									{ Name = unName, Args = {}, Prefixes = command.Prefixes, ArgPos = 0 }
								)
								if #suggestions == props.maxSuggestions then
									break
								end
							end
						end
					end
				elseif props.currentBarCommand or specificArg then
					local cArg
					if specificArg then
						cArg = specificArg
					else
						cArg = props.currentBarCommand.Args[totalArgs]
					end
					local newSuggestion = {}
					local currentBarArg = string.lower(args[totalArgs])
					local endChar = string.sub(props.textBox.Text, -1)
					if endChar ~= " " and endChar ~= main.pdata.SplitKey then
						if cArg == "player" or cArg == "playerarg" then
							for i, v in pairs(main.qualifiers) do
								if collectArguments(suggestions, currentBarArg, totalArgs, v) then
									break
								end
							end
							if #suggestions < props.maxSuggestions then
								for i, plr in pairs(main.players:GetChildren()) do
									if collectArguments(suggestions, currentBarArg, totalArgs, plr.Name) then
										break
									end
								end
							end
						elseif cArg == "colour" or cArg == "color" or cArg == "color3" then
							for i, v in pairs(main.colors) do
								if collectArguments(suggestions, currentBarArg, totalArgs, v) then
									break
								end
							end
						elseif cArg == "material" then
							for i, v in pairs(main.materials) do
								if collectArguments(suggestions, currentBarArg, totalArgs, v) then
									break
								end
							end
						elseif cArg == "rank" then
							for _, rankDetails in pairs(main.settings.Ranks) do
								if collectArguments(suggestions, currentBarArg, totalArgs, rankDetails[2]) then
									break
								end
							end
						elseif cArg == "team" or cArg == "teamcolor" then
							for _, team in pairs(main.teams:GetChildren()) do
								if collectArguments(suggestions, currentBarArg, totalArgs, team.Name) then
									break
								end
							end
						elseif cArg == "morph" then
							for morphName, _ in pairs(main.morphNames) do
								if collectArguments(suggestions, currentBarArg, totalArgs, morphName) then
									break
								end
							end
						elseif cArg == "tools" or cArg == "gears" or cArg == "tool" or cArg == "gear" then
							for toolName, _ in pairs(main.toolNames) do
								if collectArguments(suggestions, currentBarArg, totalArgs, toolName) then
									break
								end
							end
						end
					end
				end
			end

			props.suggestionDisplayed = #suggestions
			if
				props.currentBarCommand
				and #props.currentBarCommand.Args == totalArgs
				and props.suggestionDisplayed > 0
			then
				forceExecute = true
			else
				forceExecute = false
			end

			for i = 1, props.maxSuggestions do
				local suggestion = suggestions[i]
				local label = props.rframe["Label" .. i]
				if suggestion then
					local command = false
					if suggestion.Args then
						command = true
					end
					local UP = false
					if command and suggestion.Prefixes[1] == main.settings.UniversalPrefix then
						UP = true
					end
					local newDetail = {}
					if command then
						for i, v in pairs(suggestion.Args) do
							if not UP or v ~= "player" or v == "playerarg" then
								table.insert(newDetail, "<" .. v .. ">")
							end
						end
					end
					label.TextLabel.Text = suggestion.Name .. " " .. table.concat(newDetail, " ")
					if i == props.suggestionPos then
						label.BackgroundColor3 = props.highlightColor
					else
						label.BackgroundColor3 = props.otherColor
					end
					props.suggestionLabels["Label" .. i] = suggestion
					--
					if props.mainParent.Name ~= "CmdBar" then
						local sizeY = props.rframe.LabelTemplate.AbsoluteSize.Y
						local totalSizeY = sizeY * i
						local finalY = props.rframe.AbsolutePosition.Y + totalSizeY
						local limitY = main.gui.Notices.AbsoluteSize.Y
						if finalY + 5 > limitY then
							if not originalPosition then
								originalPosition = props.mainParent.Position
							end
							props.mainParent.Position = props.mainParent.Position - UDim2.new(0, 0, 0, sizeY)
						end
					end
					--
					label.Visible = true
				else
					label.Visible = false
				end
			end
			--
			if originalPosition and #suggestions < 1 then
				props.mainParent.Position = originalPosition
				originalPosition = nil
			end
			if #suggestions < 1 and props.mainParent.Name ~= "CmdBar" then
				props.mainParent.ClipsDescendants = true
			else
				props.mainParent.ClipsDescendants = false
			end
			--
		end
	end)
end
module:SetupTextbox("cmdbar1", mainProps)
