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
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Simple string manip.?

Previous Thread :: Next Thread 
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
11 Jul 2015 12:05 PM
local Players = game:GetService'Players';

repeat wait() until Players.LocalPlayer and Players.LocalPlayer.Character

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait();

local function SplitMsg(Message)
for i = 1,#Message do
if string.sub(Message,i,i) == "/" then
return i;
end;
end;
end;

local function FindPlayer(String)
for _,v in next,Players:GetPlayers() do
if string.lower(string.sub(v.Name,1,#String)) == string.lower(String) then
return v;
end;
end;
end;

Player.Chatted:connect(function(Message)
if string.lower(string.sub(Message,1,SplitMsg(Message))) == "kill/" then
local Player = FindPlayer(string.sub(Message,SplitMsg(Message)+1));
if Player then
Player.Character:BreakJoints();
end;
end;
end);





Im trying to do this in the most possibly inefficient way. lol.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
11 Jul 2015 12:19 PM
Learn string patterns and your destiny will be revealed.

At least, that's what happened to me.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
11 Jul 2015 12:28 PM
I think I did it, not sure.

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()

local function FindPlayer(String)
for _,v in next,Players:GetPlayers() do
if string.lower(string.sub(v.Name,1,#String)) == String then
return v
end
end
end

Player.Chatted:connect(function(Message)

Message = string.lower(Message)
local Pos = string.find(Message, "/")

if Pos and string.sub(Message, 1, Pos) == "kill/" then

local Player = FindPlayer(string.sub(Message, (Pos + 1), #Message))

if Player then
Player.Character:BreakJoints()
end
end
end)
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
11 Jul 2015 01:06 PM
i know string patterns you dingnut xD

Im trying to make inefficient admin v1 xD
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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