If you’re referring to multiple instances of the same name, then yes. for i, v in pairs (workspace:GetChildren ()) do if v.Name == "" then --do some code end end This gets all the children of the workspace & if they match a particular name some code is executed.
Full Answer
:FindFirstChild () and .Name do exactly the same thing, both checks for an object of a specified name. Basically I’m trying to use :FindFirstChild () but to check if multiple instances exist instead of only one. If they do, the next block of code will run. FindFirstChild () finds the object inside the object, Name only finds the object.
FindFirstChild is necessary if you need to verify an object something exists before continuing. Attempting to index a child by name using the dot operator throws an error if the child doesn’t exist. Use FindFirstChild to first check for Part, then use an if-statement to run code that needs it.
Therefore, you should avoid calling FindFirstChild in performance dependent code, such as in tight loops or functions connected to RunService/Heartbeat / RunService/RenderStepped.
FindFirstChild takes about 20% longer than using dot operator, and almost 8 times longer than simply storing a reference to an object. Therefore, you should avoid calling FindFirstChild in performance dependent code, such as in tight loops or functions connected to RunService/Heartbeat / RunService/RenderStepped.
Description: Returns the first child of the Instance found with the given name.
The :FindFirstChild() function returns nil if an instance with the name specified is not found (has a slightly larger overhead than direct indexing), :WaitForChild() waits for an instance (yielding the current thread until it does), if it is not found in under 5 second then an 'infinite yield' error is thrown, it's ...
Remember that Lua is case sensitive, so you need to use FindFirstChild not findFirstChild and UserOwnsGamePassAsync not UserOwnsGamepassAsync.
0:015:09GetChildren vs GetDescendants - Roblox Scripting Tutorial - YouTubeYouTubeStart of suggested clipEnd of suggested clipSo if an object is a child of something then it means it's inside of something if it's a parent ofMoreSo if an object is a child of something then it means it's inside of something if it's a parent of something.
Description: Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does. If the timeOut parameter is specified, this function will return nil and time out after timeOut seconds elapsing without the child being found.
Function of: Instance. Description: Returns an array (a numerically indexed table) containing all of the Instance 's direct children, or every Instance whose Parent is equal to the object.
Is Roblox Content Suitable for All Ages? Available on smartphones, tablets, desktop computers, the Xbox One, and some VR headsets, Roblox has an ESRB rating of E10+ for Everyone 10 and up for Fantasy Violence, which means that typical gameplay should be suitable for most kids.
Even if you set up a Roblox account with parental controls for children under 13 years old, they are still able to create multiple accounts on their device (these are often called 'ghost accounts'). This means that your child may set up a 13+ account with less parental settings.
local dict = {} for i, v in pairs (workspace.ModelName:GetChildren ()) do if dict [v.Name] then dict [v.Name] += 1 else dict [v.Name] = 1 end end for i, v in pairs (dict) do if v > 1 then --do some code end end
FindFirstChild () finds the object inside the object, Name only finds the object.
Yes, but it is easier to loop through everything in the workspace and then check if it contains something rather than looping through everything and then putting another if statement to check if it is there. If the part is something that’s located in multiple objects and wanted only a few with a certain name, then your code would work more efficient.
If you’re referring to multiple instances of the same name, then yes.
v.Name does not get the children of an instance. A second table is necessary to count the instances which occur two or more times. A working solution has been provided above