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()```
** You are now Level 4! **