This script wont work. Why?

Im trying to make a script that disables another Search bar script that just looks for the ImageButtons, but i want another one to look for a String Value’s name and value. And i want the script to activate when you press a button, and disable another script

local SearchBar = script.Parent.Parent.TextBox
local x = false

function SearchBarFunction()
	local InputText=string.upper(SearchBar.Text)
	for _,v in pairs(script.Parent.Parent.Parent.Easy.Davez:GetChildren())do
		if v:IsA("ImageButton")then
			for c,j in pairs(script.Parent.Parent.Parent.Easy.Davez:GetChildren())do
				if j:IsA("StringValue") and j.Name == "Realm" then
					if InputText==""or string.find(string.upper(j.Value),InputText)~=nil then
						v.Visible=true
					else
						v.Visible=false
					end
				end
			end
		end
	end
end

local function baby()
	script.Parent.Search.Enabled = false
	script.Sound:Play()
	SearchBar.Changed:Connect(SearchBarFunction)
end

script.Parent.Parent.World.MouseButton1Click:Connect(baby)

image
image

1 Like

Does it present errors in the console? If the answer is yes, then could you take a screenshot?

1 Like

No nothing

What do i do?? IM SUPER confused

This script causes a memory leak every time you click “World”.

1 Like

How? And how do i fix it both and the script

Script connections can overlap, SearchBar will add a new connection each time the function baby is called. Since you never disconnect it it will keep on adding connections and piling up memory slowly. Your connected function SearchBarFunction shouldn’t act differently but will lag more as the connections pile up.

It’s really hard to tell what you want to happen with this script. You can disable other scripts with the Disabled property

I’ve probably fixed the memory leak by making a seperate script inside the button, But the Textbox still doesn’t look for the value inside the stringvalue’s value.

local SearchBar = script.Parent.Parent.TextBox

function SearchBarFunction()
	local InputText=string.upper(SearchBar.Text)
	for _,v in pairs(script.Parent.Parent.Parent.Easy.Davez:GetChildren())do
		if v:IsA("ImageButton")then
			for c,j in pairs(script.Parent.Parent.Parent.Easy.Davez:GetChildren())do
				if j:IsA("StringValue") and j.Name == "Realm" then
					if InputText==""or string.find(string.upper(j.Value),InputText)~=nil then
						v.Visible=true
					else
						v.Visible=false
					end
				end
			end
		end
	end
end

SearchBar.Changed:Connect(SearchBarFunction)
script.Parent.MouseButton1Click:Connect(function()
	script.Sound:Play()
	local scr = script.Parent.Parent.Scripts
	scr.Search.Disabled = true
	scr.WorldSearch.Disabled = false
end)

image
image

Can you explain what you expect to happen and what really happens in more detail?

Why are you using string.find on a string value that isn’t relevant to the child v?

Basically whenever the user types for example “H” on the textbox

There are two values in here:
Hub
and W1: Wilderness
It looks for everything that starts with, or Has “H”, Only hub shows up. So it makes the Child of the Stringvalue that houses “H” Visible.

Also for the other question I just modified another script that just works the same way but for the names of the ImageButton

Don’t you want to search the children of the ImageButton? Is that where the StringValue “Realm” is located? I’m sorry I still don’t understand the structure, “Child of the StringValue that houses “H” Visible” is mixing me up.

	for _,v in pairs(script.Parent.Parent.Parent.Easy.Davez:GetChildren())do
		if v:IsA("ImageButton")then
			for c,j in pairs(v:GetChildren())do

OH WHOOPS

Thanks for the oversight! I didn’t see that, gimmie a sec
It works! Tysm

glad I could help! my reading comprehension is terrible at this hour :sweat_smile:

1 Like

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