Is it possible to make a script that can identify only certain parts of a word? For example...
TinDrop SteelDrop IronDrop CopperDrop BronzeDrop
Can you make it identify the words before "Drop" without including the word.
While I was thinking about this and I came to a point where this might be possible based on some other scripts I have seen.. Here is my guess about how this might be done...
Have it see how many letters are in it, then remove 4. Then have it copy everything besides the last four.. I never touched about this before but I do remember a bit about other scripts I have seen that work with this stuff.
Roblox has a neat built-in method for strings which returns the first index and last index at which a given string is found within another string. string.find
For example:
print(string.find("Hey!","!")) --4 4 print(string.find("Four","Fo")) --1 2
So, using this, we can actually take only the part of the string up to the 'Drop' part.
Since we are already being given the first index within the string at when 'Drop' occurs, we can just use the substring
method for strings to get it:
local str = "TinDrop" local find = string.find(str,"Drop") print(str:sub(1,find - 1)) --We use -1 so we don't include the 'D'
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.find
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.sub