Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to find out if a part of the name is something?

Asked by 6 years ago

Let's say I have several parts named "x.poop" and others named "x.boop" (x being different names for all the parts) in the same directory, would I be able to modify only the .poop ones?

Like "if part.Name == (has the .poop extension) then ..."

0
yeah awesomeipod 607 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Hi radus,

You can easily do this using string.sub().

Like this:

if string.sub(part.Name, 3, 6) == "poop" then
    print("It's poop.");
end

Well, hope I helped and have a wonderful day/night.

Thanks,

Best regards,

~~ KingLoneCat

0
This will take the third character and go all the way to the sixth character in the string and inclusively print that. Meaning that it will also print the 3rd and the 6th characters in the string. KingLoneCat 2642 — 6y
0
Not print but, compare that. KingLoneCat 2642 — 6y
0
thanks that seems to work! radusavin366 617 — 6y
0
Good. KingLoneCat 2642 — 6y
Ad

Answer this question