Finding Object in A Table with string | Scripting Support - Unsolved

Hello everyone!
Sorry to interrupt but i think i need help in finding an object from a table using strings.
My goal is to print the match object’s value. But it keeps sending me error outputs and sometime it’s nil. Here is the code:

local object = script.Parent

local structure_array = string.split(object.Name,"_")
print(structure_array[1])
print(structure_array[2])
local extensionid = game.Workspace:FindFirstChild("folder").ExtensionID:GetChildren()

structure_array[1] = table.find(extensionid,structure_array[1]).Value

print(structure_array[1])

Alternatives: (Results Nil)

local object = script.Parent

local structure_array = string.split(object.Name,"_")
print(structure_array[1])
print(structure_array[2])
local extensionid = game.Workspace:FindFirstChild("folder").ExtensionID:GetChildren()

structure_array[1] = table.find(extensionid,structure_array[1])
structure_array[1] = structure_array.Value

Screenshot using Main script:


Screenshot using Alternative script:

Thanks for helping me, have a nice day devs!

1 Like

table.find() results in Nil if you plug in a string that cant be found.

Have you tried indexing the table as

structure_array[extensionid]?

Also, why are you calling.Value? Is it an instance value?

For this, yes i’m trying to call the object’s value (The objects in the extensionid are NumberValue)

Also i don’t understand which line should i put the index you told me.
Thank you for telling me that using table.find would result nil.

Can you send the whole script here so I can get a better understanding of it? I also will need the full output

Here you go!

wait(1)
-- // script // --

local object = script.Parent
print(object.Name)

local structure_array = string.split(object.Name,"_")
print(structure_array[1])
print(structure_array[2])
local extensionid = game.Workspace:FindFirstChild("folder").ExtensionID:GetChildren()

structure_array[1] = table.find(extensionid,structure_array[1])
structure_array[1] = structure_array.Value

print(structure_array[1])

Output Screenshot:

Screenshot of studio:

Ahh, I see, you’re using table.find() wrong + indexing your tables incorrectly. Should be:

wait(1)
-- // script // --

local object = script.Parent
print(object.Name)

local structure_array = string.split(object.Name,"_")
print(structure_array[1])
print(structure_array[2])
local extensionid = game.Workspace:FindFirstChild("folder").ExtensionID:GetChildren()

structure_array[1] = extensionid[structure_array[1]]

print(structure_array[1].Value)

Oh no

Would be even better if you did instead of extensionid all together you just used:

wait(1)
-- // script // --

local object = script.Parent
print(object.Name)

local structure_array = string.split(object.Name,"_")
print(structure_array[1])
print(structure_array[2])

structure_array[1] = game.Workspace:FindFirstChild("folder").ExtensionID:FindFirstChild(structure_array[1])

print(structure_array[1].Value)

This version is working.
Thank so much for helping me!

Nice to meet you, Have a nice day!


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.