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
 

How to See What a Message Contains?

Previous Thread :: Next Thread 
HailMontgomery is not online. HailMontgomery
Joined: 09 Aug 2011
Total Posts: 8257
03 Jan 2016 10:21 PM
I would like to make an RP name script, and I've gotten up to the part where you say something ( a certain phrase at this point ) and it changes your name to that, but it changes to that and only that. I would like to make it so that it only changes your name to what you say after /name.

The only code in question is this:

if message == ("/name") then

I would like it to only change your name to what you say after "/name", how would I go about doing this? Thank you!
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
03 Jan 2016 10:24 PM
if(string.sub(message,1,5) == "/name")then
local name = string.sub(message,5,#message)
print(name)
end

something like dis?
Report Abuse
LicePro is not online. LicePro
Joined: 08 Dec 2015
Total Posts: 467
03 Jan 2016 10:29 PM
game.Players.PlayerAdded:connect(function (plr)
game.Players:WaitForChild ("Humanoid")
if true then
plr.Chatted:connect (function (msg)
if msg == "/name" then
-- blah blah
Report Abuse
LicePro is not online. LicePro
Joined: 08 Dec 2015
Total Posts: 467
03 Jan 2016 10:30 PM
@Dr


You use that when you want the shorter version.


He can just do a chatted event with a parameter.
Report Abuse
HailMontgomery is not online. HailMontgomery
Joined: 09 Aug 2011
Total Posts: 8257
03 Jan 2016 10:36 PM
@Lice, if I am not mistaken, that's what I already have. Sorry for not including it in the Original Post.

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
if message = ("/name")

@Dr That is on the right track, but for some reason the name has an "e " at the beginning of it, and I can't get it to go away.
Report Abuse
LicePro is not online. LicePro
Joined: 08 Dec 2015
Total Posts: 467
03 Jan 2016 10:39 PM

function onChatted(message, player)
if message:sub(1, 5) == "/name" then
-- code
Report Abuse
HailMontgomery is not online. HailMontgomery
Joined: 09 Aug 2011
Total Posts: 8257
03 Jan 2016 10:39 PM
Ah, nevermind, I have it now:

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
if(string.sub(message,0,5) == "/name")then
local name = string.sub(message,6)

Thanks guys!
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
03 Jan 2016 10:46 PM
yeah. i counted the number wrong for the second substr, sorry bout that.
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