If I have StringValues that are each named a number, 1,2,3,4,5 (and so on) How can I create a script using :GetChildren() which gets the first StringValue that has no .Value and adds a value to it?
Like if "1" has a value, but "2" doesn't, "2" would get the value "Ketchup" (All the numbers after 2 would still have no .Value)
This can be done using a General For Loop to iterate through all of the Children of an object and compare their values to an empty string, then break
ing the loop. Here's some code to do that.
function writeToFirstEmptyStringValue(obj, newValue) for _, v in ipairs(obj:GetChildren) do if v.IsA("StringValue") then if v.Value == "" then v.Value = newValue break end end end end writeToFirstEmptyStringValue(workspace.StringValues, "Ketchup")
If my answer solved your problem please don't forget to accept it. Thanks!