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 » Scripting Helpers
Home Search
 

Re: Difference between :GetPlayers() and :GetChildren()?

Previous Thread :: Next Thread 
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
11 Apr 2014 11:01 PM
I made a script that works:
while true do
wait(10)
chicken = game.Players:GetChildren()
for _ = 1, #chicken do
chicken[_].Character.Humanoid.Health = 0
end
end

But why wouldn't this work?
while true do
wait(10)
chicken = game.Players:GetPlayers()--Difference is right here
for _ = 1, #chicken do
chicken[_].Character.Humanoid.Health = 0
end
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Apr 2014 11:02 PM
It should work, is there an output
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
11 Apr 2014 11:04 PM
Yea but it doesn't say anything, I started a server, but only the first one works.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Apr 2014 11:05 PM
Try adding a print(unpack(chicken)) right after you define it for both. Is there anything in the second script?
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
11 Apr 2014 11:06 PM
No it's one script, I just traded the code and started new servers.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Apr 2014 11:09 PM
No wonder why...

The first loop is infinite and is not going to reach the next.
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
12 Apr 2014 12:10 AM
No, that's not it. I put one script into the game at a time, then put the other, and test it. Only one script works. Just the second one doesn't seem to work.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Apr 2014 12:14 AM
Try the second one alone.
Because that is 1 problem, and should be the only problem in theory.
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
12 Apr 2014 12:15 AM
1st one kills players every 10 seconds, second one kills them once then does nothing... And the output is empty.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Apr 2014 12:18 AM
I'm saying only put the second one in the game and test it (completely remove the one with GetChildren)
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
12 Apr 2014 12:19 AM
I did.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Apr 2014 12:21 AM
Well the only difference between getplayers and getchildren is that getplayers only gets objects with the classname of player, so that shouldn't be causing the problem.

Try this:

while true do
wait(10)
local chicken = game.Players:GetPlayers()
for _ = 1, #chicken do
chicken[_].Character.Humanoid.Health = 0
end
end
Report Abuse
ixClassic is not online. ixClassic
Joined: 16 Jun 2012
Total Posts: 445
12 Apr 2014 12:27 AM
Alright i'll have to wait until tomorrow, i'll let you know if it works!
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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