So, I have a website gui that checks if the search bar text is the same as a value in a table.
But, when I click the “Go” button on my UI, it prints “Invalid URL”, however, it’s not “invalid”. I know this because when I print the table, it has the URL.
Code:
local pages = script.Parent.Parent.Parent.Bg.Pages
local search = script.Parent.Parent.Parent.Bg.Bar.Search.SearchBox
local enter = script.Parent.Parent.Parent.Bg.Bar.Search.Enter
local validURL = {}
for i, v in pairs(pages:GetChildren()) do -- Adds each page to the table
table.insert(validURL,v.URL.Value)
wait(2)
print(validURL)
end
enter.MouseButton1Click:Connect(function()
for i, v in pairs(validURL) do
if search.Text == v then
print("Valid URL")
else
print("Invalid URL") -- URL is in the table (as seen above)
end
end
end)
Output (table):
Please help!
EDIT: it also prints “Invalid URL” if I change it to "if v == search.Text then"
if search.Text == v then is the same as if v == search.Text then, the order of operands in a single comparison operation does not matter.
Try printing ‘search.Text’ and ‘v’ when they’re being compared, you may notice an unexpected difference between the two (unintended whitespaces, mispellings etc.).