I want to make a script that will split a table into multiple variables. Example: {[1]aa,[2]word,[3]another word} into mutliple variables called arg1, arg2, arg3… It has to work with infinite stuff
The issue is it doesnt work it just spams nil on me and sometimes a word idk why.
Trying random stuff if it maybye works. But it didnt
function FireCommand(fullcmd)
local params = {}
for word in fullcmd:gmatch("%S+") do table.insert(params, word) end
while wait(0.05) do
local count = 1
if params[count] == nil then break else
count = count + 1
print(params[count])
end
end
end
Just remove nil manually by first looping in pairs (so you can continue if nil is encountered) and inserting non-nil elements into a new table, then store each element of the new table as a variable.
You could also try storing each element in a dictionary, associated with a key (essentially the ‘variable’) by doing this
local keys = {}
for i = 1, #array do
keys["var"..i] = array[i]
end