"Rock" .. #area is just "Rock2".
If you mean "Rock" and then a number...
if part.Name:match("Rock%d+") == part.Name then
It might be simpler to just say "begins with "Rock"":
if part.Name:sub(1, 4) == "Rock" then
If you mean the name is contained in the list rockNames, then you would have a loop (or a function which uses the loop, which I'll do here)
function contains(tab, element)
for _, value in pairs(tab) do
if value == element then
return true
end
end
end
.....
if contains( rockNames, part.Name) then
Overall, it would be better to use a consistent name/detection method for all "Rock" objects (if not name, then for instance :FindFirstChild("Rock"))
They are all Rocks. If you want to give them a number, use a NumberValue or IntValue object. etc.
1 comment
if part.Name == "Rock1" or part.Name == "Rock2" and part:IsA("Model") then --code end