So ~6 hours ago, before the update, table.concat()
worked fine but now it errors because the table contains instances.
Here’s the problematic line:
print(string.format("%s has %s as dependencies", tostring(currentButton.Name), table.concat(currentButton.DependOn:GetChildren(), ", ")))
And here’s the error:
(it says that it’s on line 75 and also 64 but that’s because I use a coroutine)
I tried searching a function to convert every value in a table to a string but without success.
Any help is appreciated!
Artzified
(Artzified)
May 10, 2023, 1:33pm
#2
thats because the contents of the :GetChildren()
is a bunch of Instance
’s
2 Likes
Yes I know, said it in the original post, but it used to work a few hours back.
My question is that is there any way to transform all the instances into strings, even with :GetChildren
?
Artzified
(Artzified)
May 10, 2023, 1:39pm
#4
a lazy solution is that you could do a for loop and insert the name of each instance to a table
Thank you, I’m going to try it. But are there any other more efficient solutions, especially just for a print()
statement?
1 Like
Artzified
(Artzified)
May 10, 2023, 1:43pm
#6
you can concatenate the name onto a string variable instead:
local joined = ''
for _, v in instances do
joined ..= v.Name
end
1 Like
Artzified
(Artzified)
May 10, 2023, 1:44pm
#7
oh for that you can use table.foreach(print)
(would just print it individually instead of one string if that whats you want)
1 Like
Strixial
(Strixial)
May 10, 2023, 1:45pm
#8
isnt foreach deprecated though?
(to add to the conversation: what i’d do is something like:
print((function() local s = "" for i, v in pairs(currentButton.DependOn:GetChildren()) do s = s..v..", " end return s)())
Artzified
(Artzified)
May 10, 2023, 1:46pm
#9
i dont think so, its still visible on the table documentation with show deprecateds off
1 Like
But it doesn’t work anymore, it just returns nil now.
(And Studio underlines it in yellow and says that it is deprecated)
Strixial
(Strixial)
May 10, 2023, 1:48pm
#11
based on this post im pretty sure it is deprecated
1 Like
Artzified
(Artzified)
May 10, 2023, 1:49pm
#12
oh, that’s weird, sorry for the confusion
table.foreach() doesn’t work, if that’s what you were asking for
1 Like
system
(system)
Closed
May 24, 2023, 1:52pm
#15
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.