So, I have a multiple Frame named as “BGX_~” and my problem is, How do I check if their name is starting with “BGX”?
I know the solution is string.~() but I don’t know how to do the proper syntax for it.
Sample Code:
for _, Frame in pairs(MainFrame:GetChildren()) do
if Frame.Name == string.find("BGX") then --This is only sample because I don't know what to use.
Frame.Visible = false
end
end
string.find returns two numbers, the starting and ending point of the match, and you are trying to compare a string to the first number, which obviously results in false. Numbers are truthy, so what I showed works fine.
The function returns nil if no match was found, and nil is falsey, so it would then just not do anything.
local Frame_1 = "BGX_FRAME_1"
local Frame_2 = "BGX_FRAME_2"
local CollectFrames = {Frame_1, Frame_2}
for _, Frame in pairs(CollectFrames) do
if string.find(Frame, "BGX") then
print("TRUE")
else
print("FALSE")
end
end