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: For loop fail? :I

Previous Thread :: Next Thread 
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:02 PM
This isn't the whole script but it errors in this part. I don't know what's wrong :(


for i = 1, #game.Players:GetPlayers() do
local tl = Instance.new("TextLabel", sg)
tl.Name = game.Players[i].Name
tl.Text = game.Players[i].Name
tl.Position = UDim2.new(0, 0, 0, 20 * i)
tl.Size = UDim2.new(1, 0, 0, 20)
tl.BackgroundTransparency = 1
tl.Font = "ArialBold"
tl.FontSize = "Size24"
end
Report Abuse
RobloScripts is not online. RobloScripts
Joined: 10 Nov 2012
Total Posts: 587
15 Nov 2012 08:04 PM
Do the output see where the error is I'm to lazy to search
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:07 PM
I can only test this in-game :L
It's an admin command script. Everything works until I change the text though. The text won't change.
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:21 PM
Bump. :I goobypls!
Report Abuse
Uuvinu is not online. Uuvinu
Joined: 19 Apr 2012
Total Posts: 2206
15 Nov 2012 08:25 PM
Use ROBLOX's remote control script model thingy.

It'll show you the error in online mode.
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:26 PM
Oh yea. I forgot I had that. Thanks.
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:29 PM
Output:

1 is not a valid member of Players.


I know what this means, but I don't know how I would fix it. :I
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
15 Nov 2012 08:30 PM


    tl.Name = game.Players:GetPlayers()[i].Name
    tl.Text = game.Players:GetPlayers()[i].Name

¤¤ †KMXD† ¤¤
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:31 PM
Thankyou v_v
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
15 Nov 2012 08:31 PM
No problem.

¤¤ †KMXD† ¤¤
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
15 Nov 2012 08:33 PM
More efficient to do,

for num,player in pairs(game.Players:GetPlayers())do
-- stuff
tl.Text = player.Name
end
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:35 PM
Another output now,

attempt to call field 'Players' (a userdata value)

:L
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
15 Nov 2012 08:36 PM
Code? And what line?
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:38 PM
for i = 1, #game.Players:GetPlayers() do
local tl = Instance.new("TextLabel", sg)
tl.Name = game.Players:GetPlayers()[i].Name -- THIS ONE!
tl.Text = game.Players:GetPlayers()[i].Name
tl.Position = UDim2.new(0, 0, 0, 20 * i)
tl.Size = UDim2.new(1, 0, 0, 20)
tl.BackgroundTransparency = 1
tl.Font = "ArialBold"
tl.FontSize = "Size24"
end
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
15 Nov 2012 08:40 PM
for i,player in pairs(game.Players:GetPlayers())do
local tl = Instance.new("TextLabel", sg)
tl.Name = player.Name
tl.Text = player.Name
tl.Position = UDim2.new(0, 0, 0, 20 * i)
tl.Size = UDim2.new(1, 0, 0, 20)
tl.BackgroundTransparency = 1
tl.Font = "ArialBold"
tl.FontSize = "Size24"
end
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
15 Nov 2012 08:47 PM
It works, thanks. :)
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