I only want it to print those that are NOT {}
, yet it still prints them. Thanks!
I only want it to print those that are NOT {}
, yet it still prints them. Thanks!
It’s possible that it’s a string, and not an array.
If you replace {} with "{}"
does it have any impact?
Edit: Alternatively, you can do
if #v.Icon > 0 then
This checks if the number of elements is more than 0
Not entirely sure what a check of any object against {} would return. Looks to me like a conditional check with {} would be against an empty table. Is v.Icon
a table? I assume it fails every time because v.Icon
is in-fact not an empty table.
If you replace {} with
"{}"
does it have any impact?
Already tried that, and it didn’t, hence why I made a forum post.
if #v.Icon > 0 then
It always is false. type(v.Icon)
returns table
btw, maybe that’s causing all my issues :p
I would suggest checking what is making v.Icon
a table.
what is v
?
If it’s always false, then there’s nothing that should print ever, hence there’s no need for the print statement
local AllAdditionalInfoData = RequestAllOrSpecificAdditionalInfoRemoteFunction:InvokeServer() -- returns a GetAsync: on the server script
if AllAdditionalInfoData then
for i, v in AllAdditionalInfoData do
print(type(v.Icon))
if #v.Icon > 0 then
print(v.Icon)
end
end
end
Does this help out? Here is all of AdditionalInfoData:
Occasionally Icon
it has some data in it:
And this:
ah, so it’s a dictionary.
I guess you can try modifying the code I sent above to work with dictionaries:
local hasElement = false
for _, _ in pairs(v.Icon) do
hasElement = true
break
end
if hasElement then
print(v.Icon)
end
It works! Thank you :D
for _, _ in pairs(v.Icon) do
print(v.Icon)
-- my function
break
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.