EcIiptic
|
  |
| Joined: 12 Aug 2009 |
| Total Posts: 13737 |
|
|
| 29 Dec 2013 04:42 PM |
Okay does anyone know a tutorial on how to use string.sub in admin commands?
Or if someone can give me a brief example on how to use it? |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:50 PM |
There is some videos in this playlist on making admin commands.
I would recommend watching the non-admin command ones too but not necessary.
If you plan on making admin commands that are fairly long. You should learn pattern matching. It will make it a lot easier that just using subs. youtube /watch?v=Urvn69ZbM_Y&list=PL8A3AFE78FAF8CF49 |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2013 04:52 PM |
| http://wiki.roblox.com/index.php/Function_dump/String_manipulation#string.sub |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 29 Dec 2013 04:55 PM |
print(string.sub("YELLO", 1,3)) --prints Characters 1 through 3 -->YEL
print(string.sub("YELLO", 2))--prints Characters 2 through the rest of the word -->ELLO
--Without finding patterns, this is a basic way to use string.sub()
game.Players.PlayerAdded:connect(function(p) game.Players.PlayerAdded:connect(function(p) p.Chatted:connect(function(msg) if msg:lower():sub(1,5) == "kill/" then --Find the command local plr = game.Players:findFirstChild(msg:sub(6)) --Find the players name starting at the 6th character. if plr then Instance.new("Hint", p.PlayerGui).Text = "Killing "..plr.Name end end end) end) |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 29 Dec 2013 04:56 PM |
*
game.Players.PlayerAdded:connect(function(p) p.Chatted:connect(function(msg) if msg:lower():sub(1,5) == "kill/" then --Find the command local plr = game.Players:findFirstChild(msg:sub(6)) --Find the players name starting at the 6th character. if plr then Instance.new("Hint", p.PlayerGui).Text = "Killing "..plr.Name end end end) end) |
|
|
| Report Abuse |
|
|