|
| 04 Nov 2017 09:26 PM |
| I was creating a teleport script so when someone typed in a text box something specific, it tps them. My thought process was that I could be looking in between the 1st space and the 2nd one would be one name. In between the end and the 2nd space would be the second person. I managed to get around that but I had the same problem again. I know string.match should have what I am looking for but I don't know how to code how to detect the space or what parameters are needed. It would be even better if you explained what each one did. (s, pattern [, init]) |
|
|
| Report Abuse |
|
|
|
| 04 Nov 2017 09:27 PM |
| Show the script so we (Scripters) can see. |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
| |
|
kylerzong
|
  |
| Joined: 06 Aug 2011 |
| Total Posts: 659 |
|
|
| 04 Nov 2017 09:30 PM |
paystebin com/M0zY5h8j
local string = "player1 player2"
local words = module:parse(" ",string)
print(words[1]) print(words[2])
Output: player1 player2 |
|
|
| Report Abuse |
|
|
|
| 04 Nov 2017 09:34 PM |
Not much more to see besides what I said but here it is:
if script.Parent.Click.TextBox.Text:sub(1, 4) == "warn" then local TargetPlayer = game:GetService("Players").Players:FindFirstChild(script.Parent.Click.TextBox.Text:sub(4)) if TargetPlayer then TargetPlayer.StarterGui.Warning.Text = TargetPlayer.StarterGui.Warning.Visible = true wait(2.5) TargetPlayer.StarterGui.Warning.Visible = false end end
I am just trying to figure out how to allow someone to give a reason for the warning, then put it into the text value |
|
|
| Report Abuse |
|
|
|
| 04 Nov 2017 09:53 PM |
Oh, you want to do something like that?
local reason = "Life"
function WarnExample() print("You have been warned. Reason: " .. reason) end |
|
|
| Report Abuse |
|
|
|
| 04 Nov 2017 10:02 PM |
| Yes but that is not my problem I was encountering. So I have someone click on a gui, enter the command, but with this command, I need to somehow separate the person and the reason. So back to the idea of finding the spaces! |
|
|
| Report Abuse |
|
|
soutenu
|
  |
| Joined: 09 Dec 2011 |
| Total Posts: 1021 |
|
|
| 04 Nov 2017 10:04 PM |
local str = 'Player1 player_2';
for p in str:gmatch'%w+%_*%w*' do print(p); end; |
|
|
| Report Abuse |
|
|