-
What do you want to achieve? Keep it simple and clear!
removing void from a table/resorting indexes so there arent any empty indexes -
What is the issue? Include screenshots / videos if possible!
im making a dialogue system that uses tables and the indexes in the table for it, sometimes (most of the time) it adds “void”, which breaks my script and also it sometimes just doesnt add anything but skips the index -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i looked through devforum and the api reference for tables, still dont know why this happens
this is what i expect would come out
{
[1] = "hello world"
[2] = "dialogue2"
[3] = "dialogue3"
[4] = "ok bye"
}
but sometimes it does one of these two, for example
{
[1] = "hello world"
[2] = "dialogue2"
[3] = void
[4] = "dialogue3"
[5] = "ok bye"
}
or
{
[1] = "hello world"
[2] = "dialogue2"
[3] = "dialogue3"
--comepletely skips "4" and it just isnt there
[5] = "ok bye"
}
code im using to insert the values:
local
dialogSort = {}
function insertDialog (pageVal)
--for inserting the values name and value into the table
local pageText = pageVal.Value
local pageName = pageVal.Name
local pageNum = tonumber(pageName)
table.insert(dialogSort, pageNum, pageText)
end
--remotevent from proximityprompt (sends a folder with stringvalues)
diaStart.OnClientEvent:Connect(function(pages)
for i,v in pairs(pages:GetChildren()) do
insertDialog(v)
end
end)
ive also realized now i couldve just fired a table with the remotevent so i dont have to go through the trouble of inserting and clearing one table
but id still like an answer just incase i come by it again
any help on this would be helpful, im still learning tables so if its a mistake i did just lmk, thanks