String.gsub is returning text with number

Hello!
Why does string.gsub returning text with number?

string.gsub("hello world", ' world', '')

is returning “hello 1”
but i need only text

How to get only text without number at the end?

That function returns two values, the first being the new string and the second being a number of how many substitutions were made. In your case you’re only going to want the newString

local newString = string.gsub("hello world", ' world', '')
print(newString) -- should return "hello"
1 Like

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