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
 

Would this work

Previous Thread :: Next Thread 
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
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 is not online. 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
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
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 is not online. 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 is not online. 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
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
23 Apr 2015 06:20 PM
ohh thanks :)
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