Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to pull 3 arguments from a string?

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

✓ Accepted answer

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!

3 comments

0

There's a better way to do it, but it's much more advanced.

0

Thanks Ill try this!

0

No problem! Glad to help! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.