title explains it all, i want to get a objects name and then remove all spaces from it
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+", "")