local CanBeSeen = {["Nothing"] = game:GetService("Workspace").Scripting.CamNothing
}
local function findArray(name: string | number | boolean)
local found = false
local indexInt = 0
for index, value in CanBeSeen do
if found == false then
indexInt += 1
if index == name then
found = true
end
end
end
if found == true then
return indexInt
else
return nil
end
end
print(findArray("Nothing"))
But is there a way to insert using table.insert method this in a table for exemple ? ["Base"] = game:GetService("Workspace").Baseplate
Or change the table for the FindArray can detect that : local CanBeSeen = {{["Nothing"] = game:GetService("Workspace").Scripting.CamNothing}}
i have provided an example in my post above on how to insert and change the value in a table at given index
yes thats because you need to tell this function in which table to search. the first argument would be the table to search in and the second argument would be the value to search for
also actually my bad table.find returns index of wanted value if there is any while your function searches for matching key in the table and returns how many keys it has gone through before finding desired one if there is one
could you please explain what are you trying to achieve because i cant see any use of this function above
i have opted for a better solution to do a table in a table like that :
local CanBeSeens = {
{[“Nothing”] = game:GetService(“Workspace”).Scripting.CamNothing}
}
local function findArray(name)
local found = false
local indexInt = 0
for array,tab in ipairs(CanBeSeen) do
indexInt +=1
print(array, tab)
if tab[name] then
found = true
return indexInt
end
if found == false then
return nil
end
end
end
And for insert : table.insert(CanBeSeen, {[v.Name] = v.Character.Head})