Gmatch doesnt seem to be working?

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’

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)

I did this instead and it seems to work:

Character.Stats.Abilities.Value:gsub("[^,]+",function(c) table.insert(Abilities,c) end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.