Glitch with textbox search system

How come when i highlight the text and change it to something, the results differ from just typing that thing in the first place(refer to video below)

Script?

thatd be a scripting thing. provide us with a script so we can furthermore help

local player = game.Players.LocalPlayer
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text ~= "" then
		local text = string.upper(script.Parent.Text)
		for i, child in pairs(script.Parent.Parent.PetFrame.ScrollingFrame:GetChildren()) do
			if child:IsA("TextButton") then
				local petName = string.upper(child.PetName.Value)
				if string.match(petName,text) then
				else
					child.Visible = false
				end
			end
		end
	else
		for i, child in pairs(script.Parent.Parent.PetFrame.ScrollingFrame:GetChildren()) do
			if child:IsA("TextButton") then
				if child.Name ~= "Template" then
					child.Visible = true
				end
			end
		end
	end
end)

You didnt make them visible

if string.match(petName,text) then
-- where is the part making it visible???
				else

You sure that’s the most recent script? There’s nowhere where you make the frame visible, or where you check the pet name for partial characters.