So I have a string like this:
local str = "Hello Friends "
how do i remove that space after friends? as its not needed
I'm not exactly sure why you need this, but here is the code for removing a space from after friends:
local s = "Hello Friends " local x = (s):gsub(" $", "") print(x.."No space") --Prints: --Hello FriendsNo space
The parenthesis after gsub includes string manipulation characters (they're called wildcards). Basically you're searching the string with the parameters you provide and replace it with what's inside the last quotes. In this case I first add a space in the first quotes. The $ is an anchor point for the end of the string.