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

Finding part with string.match? [closed]

Asked by 5 years ago

I need to find a part with nuke in it's name, any help?

0
THIS WEBSITE ISNT FOR US TO WRITE SCRIPTS FOR YOU WHAT DO YOU THINK WE ARE FREE WORKERS?!? Zenith_Lord 93 — 5y
0
We are not scriptersforhire.org, neither are we slaves. User#19524 175 — 5y

Closed as Not Constructive by User#19524

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago

If you know what the part's parent is going to be, iterate through its children and use string.match on each of their names

for i,v in pairs(Parent:GetChildren()) do --i is index (the child's number in the hierarchy) and v is value(the part)
    if v.Name:lower():match("nuke") then --if the lowercase version of the name has nuke in it then
        --code here
    end
end

replace 'Parent' by the part's parent location in the game hierarchy

Ad