Hey,
I tried to find help for my issue, but those solutions were not helpful for me. I want a search system that searches for the items the player enters into the search bar (textbox) and then arranges them in the correct order, hiding the others that do not match the results. For example, if you enter ‘Crea,’ it searches for all the titles that start with ‘Crea’ and hides the others that do not start with ‘Crea.’ The code contains all the locations and titles that I have.
They are not searched by the names of those TextButtons but by the texts on the TextButtons, i.e., TextButton.Text. Can you help me with this? Here is my code outline that currently hides everything and does not display anything, no matter what I enter:
local search = script.Parent
local title1 = script.Parent.Parent.hiiret.e1
local title2 = script.Parent.Parent.hiiret.e2
local title3 = script.Parent.Parent.hiiret.r1
local title4 = script.Parent.Parent.hiiret.r2
local title5 = script.Parent.Parent.hiiret.r3
local title6 = script.Parent.Parent.hiiret.r4
local title7 = script.Parent.Parent.hiiret.s1
local title8 = script.Parent.Parent.hiiret.s2
local title9 = script.Parent.Parent.hiiret.l1
local title10 = script.Parent.Parent.hiiret.l2
local title11 = script.Parent.Parent.hiiret.m
local title12 = script.Parent.Parent.hiiret.vip
local titlepos1 = title1.Position
local titlepos2 = title2.Position
local titlepos3 = title3.Position
local titlepos4 = title4.Position
local titlepos5 = title5.Position
local titlepos6 = title6.Position
local titlepos7 = title7.Position
local titlepos8 = title8.Position
local titlepos9 = title9.Position
local titlepos10 = title10.Position
local titlepos11 = title11.Position
local titlepos12 = title12.Position
local hiiret = script.Parent.Parent.hiiret
local search = script.Parent
local originalPositions = {
Squirrel = hiiret.r1.Position,
Coder = hiiret.r2.Position,
Sauna = hiiret.r3.Position,
QWERTY = hiiret.r4.Position,
Nut = hiiret.s1.Position,
Helper = hiiret.s2.Position,
Epic = hiiret.e1.Position,
Creative = hiiret.e2.Position,
Master = hiiret.l1.Position,
M3CHA = hiiret.l2.Position,
PlayerChosen = hiiret.m.Position,
VIP = hiiret.vip.Position,
}
local function updatePositions(query)
query = query:lower()
local visibleTitles = {}
local yOffset = 0
for name, position in pairs(originalPositions) do
local title = hiiret:FindFirstChild(name)
if title and title:IsA("TextButton") then
local titleText = name:lower()
if titleText:find(query, 1, true) then
table.insert(visibleTitles, title)
title.Position = UDim2.new(position.X.Scale, position.X.Offset, position.Y.Scale, yOffset)
yOffset = yOffset + position.Y.Offset
else
title.Position = UDim2.new(position.X.Scale, position.X.Offset, 2, 0)
end
end
end
for _, title in pairs(hiiret:GetChildren()) do
if title:IsA("TextButton") and not table.find(visibleTitles, title) then
title.Position = UDim2.new(0, 0, 2, 0)
end
end
end
search:GetPropertyChangedSignal("Text"):Connect(function()
updatePositions(search.Text)
end)
This is how my buttons are arranged within the frame. The red one is the button where you can enter your own text, which complicates this search system. Because it can be edited, it is textbox: