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
 

For loop doesnt run

Previous Thread :: Next Thread 
SkippinSweetPine is not online. SkippinSweetPine
Joined: 18 Apr 2011
Total Posts: 122
12 Sep 2017 09:01 PM
playerList = game.Players:GetChildren()
for i,player in pairs(playerList) do
print(player)
local experience = Players[player].leaderstats.Experience.Value
print(player)
local level = Players[player].leaderstats.Level.Value
if experience > 50 + (50 * level) then
level = level + 1
end
wait(1/12)
end

When ever I try to run this code the for loop doesn't execute, I know this as the print(player) doesnt print anything. Any help is always appreciated.
Report Abuse
Thedagz is not online. Thedagz
Joined: 10 Mar 2012
Total Posts: 798
12 Sep 2017 09:11 PM
if your running that code right when the server starts up, chances are the script ran first before the players actually had time to join the game.

or

You could have a waitforchild() delaying the thread

you should also replace :GetChildren() with :GetPlayers()



Need Help With scripting or Hire Scripters? Go here! via Discord : rfnudw6
Report Abuse
SkippinSweetPine is not online. SkippinSweetPine
Joined: 18 Apr 2011
Total Posts: 122
12 Sep 2017 09:13 PM
Im delaying it by 45 seconds, but I will try the GetPlayers() instead, thank you :)
Report Abuse
Mouse_Potatoe is online. Mouse_Potatoe
Joined: 14 Jul 2011
Total Posts: 1563
12 Sep 2017 09:37 PM
player.Name

player is an object so you want to get the name


lua_getfield(lua_State, -1, "MemeService")
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
12 Sep 2017 09:42 PM
If nothing is being printed then neither changing it to GetPlayers nor using player.Name would fix anything. Since it looks right (enough to at least print the name of the first object in Players) I would say the problem is pretty certainly elsewhere in the script.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
12 Sep 2017 09:55 PM
Boeing you're back!!!!


"player is an object so you want to get the name"
tostring on a Roblox Instance returns instance.Name, and print calls tostring. Ergo, not a requirement.


Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
12 Sep 2017 11:12 PM
I have been on for a while but usually I am on one of my tens of alts or I lose motivation midway through writing the reply because of how few interesting posts there are now...
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