So, yes… ive seen this topic, but the thing i want to learn is not this exactly… Anyway, how whould i check if a certain object is in a folder or model or even a part and how many are there and whats the name, for example: i have 3 string values and the first string value’s name is “Apple” 2nd string value’s name is “Banana” and the 3rd is “Pineapple” how whould i know this? Its been a question wondering around my brain for a while and i thought that this whould be a valuable information for me in the future… Anyways, thanks!!
Sorry, I’m a little confused here.
What are you exactly trying to do? Are you trying to find the descendants/children of something and check for the name? Are you trying to find the parent of something given the object? Are you trying to see if the object even exists where you’re checking?
Im trying to get a string value inside a folder and trying to get that string values name and the count of the string values
Do you have a discord? I’m still a little confused and would be easier if I could DM you privately.
I actually dont have it, sorry
Sending you a Message privately over devforum
There are 2 main ways:
:GetChildren(): returns a table of the object’s children.
:FindFirstChild(Name): returns the object or true if it finds an object with that name. only one
If you want to count them by name, do something like this:
local Count = {}
for _,Item in pairs(Folder:GetChildren()) do
if not Count[Item.Name] then Count[Item.Name] = 0 end
Count[Item.Name] += 1
end
if you want to check if it exists:
local Object = Folder:FindFirstChild("Apple")
Object will return the object or true depending on what you do, otherwise it will return nil.
Local stringValue = game.workspace.Folder.StringValue
Local stringValueName = stringValue.Name
You could then use Folder:GetChildren() To get everything inside the folder
I don’t know if this is exactly what you want but this is what I thought you meant
local folder = folder --put the folder path here
for i, v in pairs(folder:GetChildren()) do
if v:IsA("StringValue") then
print("the value is ".. v.Value.. " and the count's ".. i)
end
end