swadley
(zombie)
1
Im trying to seperate a string into a table using gmatch, but it doesnt seem to be working.
string.gmatch(Character.Stats.Abilities.Value, '([^,]+)')
expected: the inputed string will be seperated into a table based on when commas are used
result: “nil” for every comma
also the string is ‘PointOut,Test’
7eoeb
(beoe7)
2
string.gmatch returns an iterator looping through all the results, then you would add it to a table in the iterator.
Example:
local words = 'PointOut,Test'
local result = {}
for word in string.gmatch(words, '([^,]+)') do
table.insert(result, word)
end
print(result)
swadley
(zombie)
3
I did this instead and it seems to work:
Character.Stats.Abilities.Value:gsub("[^,]+",function(c) table.insert(Abilities,c) end)
system
(system)
Closed
4
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.