generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: How would I...(String manipulation)

Previous Thread :: Next Thread 
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
20 Jul 2013 06:32 PM
me = game:service("Players")["FriendlyScripter"]

for _,v in pairs(game.Players:GetChildren()) do

me.Chatted:connect(function(msg)
if msg:sub(1,3) == (string.sub(v.Name,1,3)) then
print(v.Name)

else
print"player not found"
end
end)
end
----


Everything works fine, it's just I want it so that if I say part of a player's name
it will still print the player's name or more

basically this part of the script needs

" if msg:sub(1,3) == (string.sub(v.Name,1,3)) then "

To be MORE BASIC for you to understand, I BASICALLY want this; to NOT error;

if msg:sub(1,3 'or more') == (string.sub(v.Name,1,3 'or more')) then


Hope you understand
Thanks! :)

Report Abuse
adark is not online. adark
Joined: 13 Jan 2008
Total Posts: 6412
20 Jul 2013 07:04 PM
me.Chatted:connect(function(msg)
for _, v in ipairs(Game.Players():GetChildren()) do
local check = false
tick = v.Name:len() <= msg:len() and v.Name:len() or msg:len()
for i = tick, 1 do

if msg:sub(1,i) == v.Name:sub(1,i) then check = true break end

end

if not check then
print(v.Name)
else
print("Player not found")
end
end
end



There's a better way to do this, more efficiently, but I can't remember what is.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
20 Jul 2013 07:06 PM
Player.Chatted:connect(function(Chat)
if Chat:lower():sub(1, 5) == "kill/" then
for _, Player in pairs(Game.Players:GetPlayers()) do
if Player.Name:lower():find(Chat:lower():sub(6)) and Player.Character then
Player.Character:BreakJoints()
end
end
end
end)
Report Abuse
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
25 Jul 2013 12:56 PM
Thank you so much cody!
I understood it 100%!
Unfortunately, I've encounterd another problem that I call "double commands"
Can you please fix this script down below?



The output says everything works just fine it's just not acting.
Report Abuse
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
25 Jul 2013 12:56 PM
The script:



me = game.Players.FriendlyScripter
me.Chatted:connect(function(msg)
for _,v in pairs(game.Players:GetPlayers()) do
for _,player in pairs(game.Players:GetPlayers()) do
if msg:lower():sub(1,4) == "'tp " then
if v.Name:lower():find(msg:lower():sub(5)) then
if (" "):find(msg.lower():sub(6)) then
if player.Name:lower():find(msg:lower():sub(7)) then

v.Character.Torso.CFrame = player.Character.Torso.CFrame



end
end
end
end
end
end
end)
Report Abuse
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
25 Jul 2013 02:48 PM
Bump!! :(
Report Abuse
xvxvpredator101 is not online. xvxvpredator101
Joined: 19 Apr 2012
Total Posts: 2059
25 Jul 2013 03:00 PM
hi guys
Report Abuse
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
25 Jul 2013 03:11 PM
Bump..!!11one!11!1!!!!1
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
25 Jul 2013 04:05 PM
local Message = "tp friend cody"

local Command, FirstArgument, SecondArgument = Message:match("(%w+) (%w+) (%w+)")

--That would only work if First and Second Argument is there.

Or

local FirstDel = Message:find(" ")
local SecondDel = Message:find(" ", FirstDel + 1)

local Command = Message:sub(1, FirstDel - 1)
local FirstArgument = Message:sub(FirstDel + 1, SecondDel - 1)
local SecondArgument = Message:sub(SecondDel + 1)
Report Abuse
FriendlyScripter is not online. FriendlyScripter
Joined: 19 Feb 2012
Total Posts: 222
25 Jul 2013 06:44 PM
^ Looks way too complicated can you please just make this one work by using that magic touch of yours?


me = game.Players.FriendlyScripter
me.Chatted:connect(function(msg)
for _,v in pairs(game.Players:GetPlayers()) do
for _,player in pairs(game.Players:GetPlayers()) do
if msg:lower():sub(1,4) == "'tp " then
if v.Name:lower():find(msg:lower():sub(5)) then
if (" "):find(msg.lower():sub(6)) then
if player.Name:lower():find(msg:lower():sub(7)) then

v.Character.Torso.CFrame = player.Character.Torso.CFrame



end
end
end
end
end
end
end)
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
25 Jul 2013 06:51 PM
function GetArgs(Message)
local FirstDel = Message:find(" ")
local SecondDel = Message:find(" ", FirstDel + 1)

local Command = Message:sub(1, FirstDel - 1)
local FirstArgument = Message:sub(FirstDel + 1, SecondDel - 1)
local SecondArgument = Message:sub(SecondDel + 1)
return Command, FirstArgument, SecondArgument
end

me = game.Players.FriendlyScripter
me.Chatted:connect(function(msg)
local Command, FirstArg, SecondArg = GetArgs(msg)
if (Command and FirstArg and SecondArg) then
if (Command == "tp") then
for Index, Player in pairs(Game.Players:GetPlayers()) do
if (Player.Name:lower():find(FirstArg:lower())) then
for Key, player in pairs(Game.Players:GetPlayers()) do
if (player.Name:lower():find(SecondArg:lower())) then
if (Player.Character:FindFirstChild("Torso") and player.Character:FindFirstChild("Torso")) then
Player.Character.Torso.CFrame = player.Character.Torso.CFrame * CFrame.new(math.random(3), math.random(3), math.random(3))
end
end
end
end
end
end
end
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image