koziahss
(Agent_Invalid)
June 29, 2021, 7:44pm
#1
So, I wasn’t sure how to word the title but here goes.
Let’s say I have a list.
Let’s say I also have an unknown amount of unique values. Let’s say I have 5 unique values (A,B,C,D,E)
Now let’s say I have a list of those unique values and they are jumbled up and some are repeated.
Like this
(A,D,B,E,B,A,C,C,E,B,D,D,A)
How would I get a list that only contains unique values?
The values are not numeric and they do not have to be in A,B,C,D,E order.
I am looking for a formula or a function that can do this. Thanks.
VeosRob
(Veos)
June 29, 2021, 7:49pm
#2
Hello,
You would have to use a https://education.roblox.com/en-us/resources/pairs-and-ipairs-intro loop to go through the array and use Control Structures | Roblox Creator Documentation to find the value you are looking for.
Let me know how it goes!
D0RYU
(nici)
June 29, 2021, 7:56pm
#3
this is really easy to do
local TestTable = {
"A",
"B",
"B",
"A",
"C",
"C"
}
function GetUniqueTable(Table)
local EndTable = {}
for i, v in pairs(Table) do
if not table.find(EndTable, v) then
table.insert(EndTable, v)
end
end
return EndTable
end
GetUniqueTable(TestTable)
D0RYU
(nici)
June 29, 2021, 7:59pm
#5
ik you deleted your post, but what was the point of redefining the global variable “in” to false?
different name would’ve been better
I deleted it because it was unnecessary. Your solution was better🤷♂️ honestly forgot everything inside as soon as I pressed delete.