How to search for a certain thing in folder

Hello, so basically I’m having trouble with the following code:

local value = game.workspace.Folder1.value
local Folder = game.ServerStorage.WeaponFolder
Folder[value.Value].Parent = game.Workspace

The value is inside of Folder1 and is a string Value…
so basically I want to search for the valuename inside of a folder but idk what I’m doing wrong…
-btw this code is an example but I don’t wanna show my actual line of coding because it would take to long to explain everything. Also if you have any questions feel free to ask.

FindFirstChild. Make sure not to assume that FindFirstChild returns an Instance as it can return nil if the name you specify doesn’t exist.

local tool = Folder:FindFirstChild(value.Value)
if tool then
    tool.Parent = workspace
end
2 Likes

when would i ever use the Folder[value.Value]

You don’t unless you can guarantee the existence of something either through well-structured code or because you explicitly define these kinds of things in code.

do you think u could a article of the Folder[value.Value]
thingy? because i would love to know more about it.

https://www.lua.org/pil/2.5.html

Indexing a child is effectively the same thing as indexing members of a table. This is from a general Lua standpoint though, from a Roblox standpoint there is no defined article for it or anything. The line Folder[value] can be read as find <value> in <Folder>.

1 Like