I need help with this search gui for chat logs and command logs

Hi, I am trying to achieve a custom chat logs list with a search gui. (already have chat logs working). Same with the command logs. I just need help with the search script, it isn’t working properly.

When I type things that are in the list, it doesn’t show them, but sometimes when I type things that aren’t in the list, it shows them.

Video of the issue:

Script for chat logs search:

local scroll = script.Parent.ScrollingFrame 
local textBox = script.Parent.TextBox 

textBox.Changed:Connect(function() changed
	local text = textBox.Text:lower() 
	if text ~= "" then -- if it has text
		local buttons = scroll:GetDescendants() 
		for _, button in pairs(buttons) do 
			if button:IsA("TextLabel") then 
				
				local buttonText = button.Text:lower() button text

				if string.find(buttonText, text) then 
					button.Parent.Visible = true 
				else -- otherwise
					button.Parent.Visible = false 

				end
	

			end
		--[[	if button:IsA("StringValue") and button.Name == "RuleText" then 
				local buttonText = button.Value:lower() 

				if string.find(buttonText, text) then 
					button.Parent.Visible = true 
				else 
					button.Parent.Visible = false 
				end
			end]]	
		end
	else -- if it's empty
		local buttons = scroll:GetDescendants()
		for _, button in pairs(buttons) do 
			if button:IsA("TextLabel") then 
				button.Parent.Visible = true 

			end
		end
	end
end)

Script for command logs:

local scroll = script.Parent.ScrollingFrame 
local textBox = script.Parent.TextBox 

textBox.Changed:Connect(function() changed
	local text = textBox.Text:lower() 
	if text ~= "" then -- if it has text
		local buttons = scroll:GetDescendants() 
		for _, button in pairs(buttons) do 
			if button:IsA("TextLabel") then 
				
				local buttonText = button.Text:lower() button text

				if string.find(buttonText, text) then 
					button.Parent.Visible = true 
				else -- otherwise
					button.Parent.Visible = false 

				end
	

			end
		--[[	if button:IsA("StringValue") and button.Name == "RuleText" then 
				local buttonText = button.Value:lower() 

				if string.find(buttonText, text) then 
					button.Parent.Visible = true 
				else 
					button.Parent.Visible = false 
				end
			end]]	
		end
	else -- if it's empty
		local buttons = scroll:GetDescendants()
		for _, button in pairs(buttons) do 
			if button:IsA("TextLabel") then 
				button.Parent.Visible = true 

			end
		end
	end
end)

This is what it looks like not playing the game.
image
And this is what it looks like playing the game.
image
image

There are no errors in the output.

Any help is appreciated.

I believe that you have an error in the loop where you check for buttons but instead you are checking for text labels

if button:IsA("TextLabel") then 

should be

if button:IsA("TextButton") then 
1 Like

Okay, I will try that script now.

Btw, how the scrolling list elements (frames) look like?

I figured it out. Your idea reminded me of something. I changed it to “getchildren” and did frame instead of textlabel. It was making the textlabel visible instead of the frame. So that’s how it could’ve been messing up.

1 Like

cool that I helped you in this way xD

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.