Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to pull 3 arguments from a string?

Asked by
Voltoxus 248 Moderation Voter
10 years ago

So I decided I wanted to make my own admin, its been going fine till I needed to figure out how to get 2 arguments instead of 1.

Example:(!tp arg1, arg2 )

How would I get argument1 and Argument2 ?

I was using ExampleString:sub(1,4) to get the command then ExampleString:sub(5) to get the first argument but now I don't know how to get the 2nd argument please help :P

1 answer

Log in to vote
4
Answered by 10 years ago

I'm not too sure what you mean by Argument 1 and Argument 2, but taking a guess, I think your talking about a speed/plr/num type command, luckily, I'm working on a Admin Commands system, so, I'm able to help you out. :D Let me show you;

if msg:lower:(1,6)sub() == "speed/" then --This checks to see if the message starts with 'speed/' [Explanation in Person299's Admin for 'kill/']; This gets the character chatted between 1 and 6
local chk1 = msg:sub(7):find("/") + 6 --This finds the '/' within 'msg:sub(7)' and returns 6 more characters
local plrz = GetPlr(plr,msg:sub(7,chk1-1)) --This will get the Player's name [If you have this function]
if plrz and plrz.Character and plr.Character:FindFirstChild("Humanoid") then --If the Player, Player's Character, and Characters Humanoid exists then
plrz.Character.Humanoid.WalkSpeed = msg:sub(chk1+1) --It'll change the WalkSpeed of the Player to the Number chosen [speed/TheAlphaStigma/16]
end --This ends the code block for the 'if' statement
end --This ends the code block for the 'if' statement

--Note-- I have tested this in my Admin, and it works. :D Hope this helped!

0
There's a better way to do it, but it's much more advanced. Tkdriverx 514 — 10y
0
Thanks Ill try this! Voltoxus 248 — 10y
0
No problem! Glad to help! :) TheeDeathCaster 2368 — 10y
Ad

Answer this question