I know how to add onto strings, it would be this for example: String.Value = "Hi"..Player.Name.."!" But how do I remove parts of a string an exmple would be I have something named "Player's_House" and I want to remove "'s_House" off of it?
How do I remove part of a string?
1 answer
This is easily accomplished with patterns! The function you need is string.gsub. This function takes in a string to replace in, a pattern, a replacement string, and optionally a limit of the number of substitutions. Patterns, which are similar in function to Regex (though far more lightweight), are a way to search for various substrings based on specified information. In this case, however, you just want to search for a specific string, "'s_House", and remove it. Thus, your code would be as follows:
string.gsub("Player's_House", "'s_House", "")
Further reading on patterns: http://www.lua.org/pil/20.2.html Further reading on the string library: http://lua-users.org/wiki/StringLibraryTutorial
3 comments
So I would do: String.Value = String.gsub("Player's_House", "'s_House", "")
Is String a StringValue? That's pretty poor naming. Also, capitalization matters, it should be 'string.gsub'.
String is a string value..
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
It's probably a wise idea to just remember the player's name in the first place (elsewhere)