0

For example, I'm trying to find every instance in Workspace that has "Ragdoll" in the name, but the ragdoll names vary and there are several of them. Here's my script so far:

for i,v in pairs(workspace:GetChildren()) do
  if v --[[script to find string inside instance name goes here]] then
  end
end
Furo
  • 1

1 Answers1

1

While I know neither lua nor Roblox, it looks from this example in the Roblox API reference that each element in the result of workspace:GetChildren() has a Name. As such, you should be able to do something like the following to determine if "Ragdoll" is a substring of each name:

local children = workspace:GetChildren()
for i, child in ipairs(children) do
    if string.find(child.Name, "Ragdoll") then
       -- (do stuff)
    end
end

See also How to check if matching text is found in a string in Lua?.

thisisrandy
  • 2,660
  • 2
  • 12
  • 25