Hey, I’m designing a system where the person’s name is stored in a String Value and a model is a child of that value to determine who owns that particular model. However, if there are duplicate models, how can I search for a model with that exact person’s value when they have the same name?
For example, I want to search for John Doe’s model in a sea of other duplicate models with the exact same name. His name is in the Value, and the model (called Scanner) is a child of that value. How can I search for the value that has John Doe’s name repeatedly until I find it? Do I use a while loop?
Thanks for reading this, and I hope I can find the answer!
You might want to rethink this system. If their is only one relation between each model and each string value, why not make the model the parent and make the string value a child of the model?
Also, I’m not completely understanding your question. In your John Doe example, do you need to retrieve every pair of John Does/Scanners, or just one? If only one, how do you determine which you need?
How can I search for the value that has John Doe’s name repeatedly until I find it?
local target = nil
for i, v in pairs(workspace:GetChildren()) do
if v.Name == "Name" and v:IsA("StringValue") and v.Value == "John Doe" then
target = v
break
end
end