#my search system is not working

1 messages · Page 1 of 1 (latest)

charred rapids
#

u can join me in studio for help i have saved everything

local searchBox = scrollingFrame.Parent.Parent.Frame2.TextBox

-- Cache pet frames and ensure they are valid
local petFrames = {}
for _, child in ipairs(scrollingFrame:GetChildren()) do
    if child:IsA("Frame") then
        table.insert(petFrames, child)
    end
end

local function filterPets()
    local query = string.lower(searchBox.Text):match("^%s*(.-)%s*$") -- Trim whitespace
    for _, item in ipairs(petFrames) do
        -- Ensure frame is still valid
        if item and item.Parent then
            local intVal = item:FindFirstChildWhichIsA("IntValue")
            if intVal then
                local petName = string.lower(intVal.Name)
                item.Visible = query == "" or petName:find(query, 1, true) == 1
            else
                item.Visible = false -- Hide frames without IntValue
            end
        else
            -- Remove invalid frame from table
            table.remove(petFrames, table.find(petFrames, item))
        end
    end
end

-- Use FocusLost for better performance and debounce
local lastQuery = ""
local debounce = false
searchBox:GetPropertyChangedSignal("Text"):Connect(function()
    if debounce then return end
    debounce = true
    task.wait(0.3) -- Debounce to prevent lag
    if searchBox.Text ~= lastQuery then
        lastQuery = searchBox.Text
        filterPets()
    end
    debounce = false
end)

-- Initial call to set visibility
filterPets()```
#

.

charred rapids
#

.

#

.

#

.

#

.

#

.

#

.

#

.

#

.

#

.

agile needle
#

This code looks AI generated and kind've hard to follow

#

What's exactly the issue?

vernal sail
#

what is not working about it and, most importantly, what steps have you taken to try to fix it?

velvet vapor
#

if you are vibe coding and have no idea what the error with your code is you need to atleast learn the basics

#

your issue is this code is extremely overcomplicated for a string.lower() string.find()

modest cradle
#

i can't read this at all

#

and its not a graphic problem

charred rapids
charred rapids
charred rapids
charred rapids
#

now im asking here

modest cradle
#

horrendously relatable

#

tho pulling this off might be difficult

charred rapids
main hingeBOT
#

studio** You are now Level 4! **studio

modest cradle
#

...a trade?

#

isn't this just to search stuff in inventory

charred rapids
vernal sail
vernal sail
charred rapids
vernal sail
#

i'm talking about in-game trading pets and whatnot

vernal sail
vernal sail
#

google it

charred rapids
modest cradle
#

"wants to make one as he is going to boarding school"