FindFirstChild (Function): Difference between revisions
From Goodblox Wiki
Jump to navigationJump to search
mNo edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
==Example== | ==Example== | ||
<pre> | <pre> | ||
while true do --Starts up a While loop | while true do --Starts up a While loop | ||
local found = workspace:FindFirstChild("Brick") --This looks in the Workspace for anything named "Brick", and sets the variable "found" to whatever object it finds. | |||
if found ~= nil then -- This makes sure that it actually found something. If the variable is nothing, then it ends. | |||
found.Name = "blah" --Sets the object's name to "blah" | |||
end --End the If loop | |||
end --End the While loop | end --End the While loop | ||
</pre> | </pre> | ||
Line 33: | Line 28: | ||
For example, if there is a part in workspace called "Part" and you use: | For example, if there is a part in workspace called "Part" and you use: | ||
<pre>workspace:FindFirstChild("Part", true)</pre> | |||
It will find the part. | It will find the part. | ||
[[Category:Functions]] | [[Category:Functions]] |
Revision as of 02:47, 22 September 2021
|
Example
while true do --Starts up a While loop local found = workspace:FindFirstChild("Brick") --This looks in the Workspace for anything named "Brick", and sets the variable "found" to whatever object it finds. if found ~= nil then -- This makes sure that it actually found something. If the variable is nothing, then it ends. found.Name = "blah" --Sets the object's name to "blah" end --End the If loop end --End the While loop
Recursive
Recursive sets whether the function should look inside of objects in the calling object, as well as the calling object.
For example, if there is a part in workspace called "Part" and you use:
workspace:FindFirstChild("Part", true)
It will find the part.