Is there a way to create an array/ table with a unique name From the data that you get from a RemoteEvent?
For Example
I have a player value and an integer, I sent them through the RemoteEvent and I want to put them in a table, then when another player value and integer is sent through it will create a table with a different name so that it doesn’t overwrite the original table.
This is for a queue system that I’m making where it takes 3 pieces of information and puts it in a table then puts that table into the Main Queue table, but I don’t want the requests to be overwritten.
I really hope I made sense while writing this, It’s a bit hard for me to explain what exactly it is that I want. Any help would be greatly appreciated.
Well, you can use this to generate a random string:
local random = Random.new()
local letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
function getRandomLetter()
return letters[random:NextInteger(1,#letters)]
end
function getRandomString(length, includeCapitals)
local length = length or 10
local str = ''
for i=1,length do
local randomLetter = getRandomLetter()
if includeCapitals and random:NextNumber() > .5 then
randomLetter = string.upper(randomLetter)
end
str = str .. randomLetter
end
return str
end
local randomNameForTable = getRandomString(math.random(5,25),true)
So if I’m understanding this right, you just want a queue system where the queue items are also tables? If so, just use table.insert() to add the table to the queue table.
Unless you change the order of the table using something like table.sort or something, yes. Tables by default will be ordered in FIFO (First In / First Out).
I understand that part, but I’m asking if I remove one table in the queue table will the others be affected the same way you mentioned they would be affected if I used table.sort()?
I’m not sure what you mean by that, but the example above should explain how table.remove works. It won’t change the order of anything in the table, but it will remove one item and move everything ahead of that item back one. So if you remove the second item, the third item will become second. table.sort will change the order of the table based on the order function you give it.