title explains it all, i want to get a objects name and then remove all spaces from it
✓ ANSWER ACCEPTED
How to remove spaces from a string?
2 answers
✓ Accepted answer
To remove spaces from a string, you can use gsub.
testStr = 'this string has many spaces'
-- Replace spaces with empty text
testStrTrimmed = testStr:gsub('%s+', '')
print(testStrTrimmed)
-- output: thisstringhasmanyspaces
-- This also works, same thing, different syntax
testStrTrimmed = string.gsub(testStr, '%s+', '')
print(testStrTrimmed)
-- output: thisstringhasmanyspaces
Hope this helps! :)
try this
name = object.Name
name:gsub("%s+", "")
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
thanks