How to I Use an Operator as Well to Check if There is a Certain String inside a Name?

Hi Other Developers,
I know how to check if there is a string inside a Instance’s Name, using string.match.
But is there a way to do something like:

string.match(newEgg.Name, ID > 10)
-- So only checking if the ID in the egg is over 10

Thanks!

1 Like

I think you would need to convert the string to a number using tonumber. But if your number is inside of the string, you would need to get the number from the string. How do I check if a string is a number? - #7 by starmaq
Personally I don’t store numbers I need to check for inside of a string.

1 Like

for example,
could i do something close to:

string.match(newBasicOre.Name, 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9)  -- not working btw

thanks

1 Like

Could you tell me how your name is set up? Like for example is it “coolDog14”?

1 Like

so it goes in a for loop,
like for i=1, 10 do
and then its set up like: Button = “Button” … i
and I want to check if the i variable in the button is higher than 5

thanks

1 Like

Can’t you just do this?

if i > 5 then

Try the following: newEgg.Name:match("Button(%d+)") > 10

it comes back with: attempt to compare string < number

no because the I is used throughout other scripts, so it would effect them as well.

1 Like

Hello, here’s a solution, If you have any questions feel free to ask.

tonumber(newEgg.Name:match("%d+")) > 10
4 Likes

ooh ok, thanks alot.
Just one last question, what does the “%d+” mean? im a bit new to scripting.
Thanks!

2 Likes

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