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: 1 is not a valid member of player?

Previous Thread :: Next Thread 
jaydan1 is not online. jaydan1
Joined: 13 Jan 2010
Total Posts: 128
01 Jul 2012 01:10 PM
This is my script.

for i, player in pairs(game.Players:GetChildren()) do
if player.PlayerGui.Config.IsPlaying.Value == true then
Cars = _G.ShownMap.Cars:children()
r = math.random(1, #Cars)
if Cars[r].Name == "Car" then
player[i].Character.Torso.CFrame = CFrame.new(Cars[r].VehicleSeat.Position) + Vector3.new(0,3,0)
end
end
end

In the output it says 1 is not a valid member of player. How do I fix this?


♦Jaydan1♦
Report Abuse
ninjaknight101 is not online. ninjaknight101
Joined: 04 Apr 2011
Total Posts: 1281
01 Jul 2012 01:20 PM
the:

for i, player in pairs() works in a special way. Player is the current value in the sequence, but "i" is the numerical count of the loop. Try no player[i].

Here:


for i, player in pairs(game.Players:GetChildren()) do
if player.PlayerGui.Config.IsPlaying.Value == true then
Cars = _G.ShownMap.Cars:children()
r = math.random(1, #Cars)
if Cars[r].Name == "Car" then
player.Character.Torso.CFrame = CFrame.new(Cars[r].VehicleSeat.Position) + Vector3.new(0,3,0)
end
end
end
Report Abuse
jaydan1 is not online. jaydan1
Joined: 13 Jan 2010
Total Posts: 128
01 Jul 2012 01:23 PM
If I do that will everybody be teleported to the same car?


♦Jaydan1♦
Report Abuse
jaydan1 is not online. jaydan1
Joined: 13 Jan 2010
Total Posts: 128
01 Jul 2012 01:29 PM
Nevermind I found a solution.


♦Jaydan1♦
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