Hey I am having a problem with a script so i need a way to find children but i only have the first letters so i have been doing something like this
--(example) Part = workspace.Baseplate for i,v in pairs(blabla:GetChildren()) do if string.sub(v.Name,1,4) == string.sub(Part.Name,1,4) then print("found") else print("not found") end end
this wouldnt work because it would go through every single one of the chldren and print when the intention is just to know if one's name is the same as the other's name
for i,v in pairs(blabla:GetChildren(" ")) do
In the quotations, put the specific name. Case and spaces sensitive(I think).
To break a loop, try to research on Roblox Wiki: Link
If you simplify want to stop the loop when you found what your looking for we can use break.
Break is used inside a loop to basically stop it.
local Part = workspace.Baseplate for i,v in pairs(blabla:GetChildren()) do if string.sub(v.Name,1,4) == string.sub(Part.Name,1,4) then print("found") break end end
This example will stop the loop when it is found