I need help, when I use gsub it splits at a _ if there's one. How do I make it keep going on the underscore?
local count1= 0 local plr= "" local reason= "" for w in string.gmatch(newchat, "%w+") do if count1 == 2 then reason= w count1= 0 elseif count1 == 1 then count1= count1+1 print("PLR:"..w) plr= w else count1= count1+1 end end
Just add the underscore to your string pattern: "[%w_]+"
for m in string.gmatch("hello this_is_a test", "[%w_]+") do print(m) end --[[ > hello > this_is_a > test ]]