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: Chat Command Target Player

Previous Thread :: Next Thread 
Zenuvius is not online. Zenuvius
Joined: 26 Aug 2014
Total Posts: 551
08 Jul 2015 02:54 PM
game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message)
processCommand(player, message)
end)
end)

function processCommand(speaker, message)
if message == ":kill" --target player
targetplayer.Character.Humanoid.Health = 0
end
end

How do I do something like ":kill Ze" and it will kill Zenuvius ?

This is a public chat command btw, I was wondering how to get the player from the message, been tinkering around with this for hours D:
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
08 Jul 2015 02:55 PM
for each player, if we find "Ze" inside of the player, add it to a list.
Once done iteration, if there is more than 1 index to the table, error. More people have Ze in the name: It is unclear who to do the command to.

Report Abuse
Zenuvius is not online. Zenuvius
Joined: 26 Aug 2014
Total Posts: 551
08 Jul 2015 03:05 PM
function findPlayer(name)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == name:lower() then
return player
end
end
end

function onChatted(message, player)
if message:sub(1, 6) == "murder" then
local victim = findPlayer(message:sub(8))
if victim and victim.Character then
victim.Character:BreakJoints()
end
end
if message == ":break" then
script.Disabled = true
end
end


game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message) onChatted(message, player) end)
end)

=============

I came up with this, but problem is murder Zen doesn't work, it only works if I say murder Zenuvius :/
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
08 Jul 2015 03:08 PM
if player.Name:lower() == name:lower() then

should be

if player.Name:lower():find(name:lower()) then

Plus... as i said... you should be popping the found value into a table or adding 1 to an integer variable to tell if there is more than 1 player with Zen or whatever.

Poor

Zenephobe

will die over

Zenfphobe
Report Abuse
Zenuvius is not online. Zenuvius
Joined: 26 Aug 2014
Total Posts: 551
08 Jul 2015 03:12 PM
I just started using Chat Commands today and I just learnt Tables a couple days ago so I'm trying to take it slowly D:

I'll get there eventually, one question though, like you said earlier, the game would be confused if there's two Zens in the game, but does that mean it will pick a random Zen or would it just break the script ?
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
08 Jul 2015 03:14 PM
Neither.

Like I said... it will kill the first Zen it finds in your case.
Report Abuse
OneShot17 is not online. OneShot17
Joined: 06 Apr 2014
Total Posts: 809
08 Jul 2015 03:16 PM
What I would do is take a free modeled admin script and look at how it works. Try to figure it out that way.
Report Abuse
Zenuvius is not online. Zenuvius
Joined: 26 Aug 2014
Total Posts: 551
08 Jul 2015 03:23 PM
Nvm, I got it, I made it return a ScreenGui that tells the player to specify which zen if there is more than 1 :D

Thanks mate ~
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