|
| 23 Apr 2015 06:00 PM |
i cant test this as im a larry so i just need clarification if this would work. Im not actually going to use this code, i just want to know if it would work so i dont get all confused. also if anyone has suggestions for a better way of doing this then please share the knowledge.
game.Players.PlayerAdded:connect(function(player) if player.Name == "enzotinman1" then player.Chatted:connect(function(msg) if msg == "KillAll" then for _,v in pairs(game.Players:GetChildren()) do if v.Name ~= "enzotinman1" then v.Character.Humanoid.Health = 0 end end end end) end end) |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 23 Apr 2015 06:03 PM |
local myName = "enzotinman1"
game.Players.PlayerAdded:connect(function(player) if player.Name == myName then player.Chatted:connect(function(msg) if msg == "KillAll" then for _,v in pairs(game.Players:GetPlayers()) do if v.Name ~= myName and v.Character then v.Character.Humanoid.Health = 0 end end end end) end end) |
|
|
| Report Abuse |
|
|
|
| 23 Apr 2015 06:14 PM |
thanks but can you explain: if v.Name ~= myName and v.Character then
why is the v.Character bit there? |
|
|
| Report Abuse |
|
|
A2D8
|
  |
| Joined: 15 Jun 2014 |
| Total Posts: 548 |
|
|
| 23 Apr 2015 06:16 PM |
| It's to make sure that the character exists. If you tried to kill someone who's already dead, it'd error and not work anymore. |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 23 Apr 2015 06:20 PM |
That checks if the player's Character is already loaded.
For example, if that was not there, and someone joined the game as you said the kill command, your code would error because it would try to access the Character of a player who's Character hasn't loaded yet. |
|
|
| Report Abuse |
|
|
| |
|