|
| 11 Oct 2016 10:14 AM |
Hello, I need help with scripting because How do you filter a word out of a text?
For example: The Noob says "hello.".
How do I filter "The Noob" And replace it with a player name for example?
I need help with this and would be very happy if I know how this works.
Thank you. |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2016 10:26 AM |
http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#string.match http://wiki.roblox.com/index.php?title=String_pattern |
|
|
| Report Abuse |
|
|
|
| 11 Oct 2016 12:46 PM |
| I want a example of a script that filters "The Noob says hello!" And filters "The Noob" out of the text and replaces it with "Player" so please give me a example instead of telling me to go to roblox wiki. |
|
|
| Report Abuse |
|
|
gskw
|
  |
| Joined: 05 Jan 2013 |
| Total Posts: 1364 |
|
|
| 11 Oct 2016 12:48 PM |
| local NewString = OriginalString:gsub(StringToFind, StringToReplaceWith) |
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 07:13 AM |
| Does the also work when the word is in upper and lowercase letters with numbers in it? |
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 07:15 AM |
| Can you do it with output or something like that? It's hard to understand. |
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 09:30 AM |
| If you filter a word out of a text, how do you replace a word in a text then? |
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 09:44 AM |
Give up
https://www.roblox.com/library/499105467/Hillary |
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 09:49 AM |
| If you don't understand what they have already said, I think you should go back to using free models |
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 09:52 AM |
you should also use the wiki
local string = "Hello Noob!" string = string:gsub("Noob", "Player")
print(string) |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 12 Oct 2016 10:21 AM |
| ############################################################################################################################################################################################################################################################################################################################################################################################# |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
|
| 12 Oct 2016 11:19 AM |
ok thanks but can you also make it filter a word even if it is typed like this. "NoOb"? Does this also work? would it be "%w(noob)" or "%wnoob%w"? help me please.
Ps I am not gonna use free models, they are Rubbush sometimes and are not how i want them to be so I rather make my own models. |
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 11:24 AM |
local Filter = {"noob"} function filter(s) for _, v in pairs (Filter) do if string.find(string.lower(s), string.lower(v)) then local repl = string.sub(s, string.find(string.lower(s), string.lower(v))) if string.lower(repl) == string.lower(v) then s = s:gsub(repl, string.rep(filterReplacement, #repl)) end end end return s end print(filter("Hello NoOb!")
|
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 11:25 AM |
Ok, I finally Understand the GSUB thing. but can you also replace a word without the gsub will put a number at the end? and what if the word is typed like "NoOb" how do you filter "noob" out of that? |
|
|
| Report Abuse |
|
|
|
| 12 Oct 2016 11:26 AM |
| http://wiki.roblox.com/index.php?title=Global_namespace/String_manipulation#string.lower |
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 11:26 AM |
print(filter("Hello NoOb!"))
|
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 11:31 AM |
oh wait, this should do it
local Filter = {"noob"} local filterReplacement= "#" function filter(s) for _, v in pairs (Filter) do if string.find(string.lower(s), string.lower(v)) then local repl = string.sub(s, string.find(string.lower(s), string.lower(v))) if string.lower(repl) == string.lower(v) then s = s:gsub(repl, string.rep(filterReplacement, #repl)) end end end return s end print(filter("Hello NoOb!"))
|
|
|
| Report Abuse |
|
|
BlueSanik
|
  |
| Joined: 01 Dec 2011 |
| Total Posts: 180 |
|
|
| 12 Oct 2016 11:39 AM |
If you want it to replace noob to a player name, just change 'string.rep(filterReplacement, #repl)'to the players name
|
|
|
| Report Abuse |
|
|