Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findFirstChild(object, property, want, recursive)
- local property, recursive, found = property or "Name", recursive or false, nil;
- local function find(obj, prop, want)
- for i,v in next, obj:GetChildren() do
- local success, bool = pcall(function() return tostring(v[prop]) == tostring(want) end);
- if (success and bool) then
- found = v;
- break;
- elseif (recursive) then
- find(v, prop, want);
- end
- end
- end
- find(object, property, want);
- return found;
- end
- ----------------------------------------------------------------------
- ----------------------------------------------------------------------
- Instance.new("StringValue", workspace).Value = "hey there!";
- local foundValue = findFirstChild(workspace, "Value", "hey there!");
- print("FOUND: "..tostring(foundValue)..";\n Value: "..foundValue.Value);
- --roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox
Advertisement
Add Comment
Please, Sign In to add comment