I have a screenGUI with multiple other TextLabels named 1-3, I also have a variable (chosenTextNumber) which chooses a random number between 1-3. Here is my code:
local chosenTextNumber = math.random(1,3)
for i,v in pairs(game.StarterGui.differentTexts:GetChildren()) do
if v.Name == chosenTextNumber then
print("HELLO THIS IS THE CORRECT THING")
print(v.Name)
end
end

5 comments
String type versus numeric type. Try
v.Name == tonumber(chosenTextNumber).That doesn't work.
I meant the other way around.
v.Name == tostring(chosenTextNumber).The point is that you need to either compare a string and a string or a number and a number. 1 isn't the same as "1".
Okay, that works. I didn't know how I would convert an integer to a string.