|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
| |
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|