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
 

what am I doing wrong?

Previous Thread :: Next Thread 
anth4321 is not online. anth4321
Joined: 22 Sep 2009
Total Posts: 29
03 Mar 2014 08:45 PM
spawns = _G.pickedMap.Spawns:GetChildren()
-- Optimize math.random
math.randomseed(tick())
-- Catch all players
players = game:GetService("Players"):GetPlayers()
-- Do the following 24 times
for i=1,100 do
-- Function is useless, if the table is clear
if #players==0 then break end
-- Choose player and Position
local current = math.random(1,#players)
local position = spawns[math.random()].Position
-- Teleport Players
if players[current] and players[current].Character then
players[current].Character:MoveTo(position)
players[current].GameStats.Alive.Value = true
end
wait()
end

no output
Report Abuse
anth4321 is not online. anth4321
Joined: 22 Sep 2009
Total Posts: 29
04 Mar 2014 08:11 AM
bump
Report Abuse
anth4321 is not online. anth4321
Joined: 22 Sep 2009
Total Posts: 29
04 Mar 2014 08:21 AM
okay sorry there was an output. here it is:
09:19:34.512 - Workspace.Main:92: attempt to index field '?' (a nil value)
09:19:34.513 - Script 'Workspace.Main', Line 92 - global teleplayers
09:19:34.513 - Script 'Workspace.Main', Line 199 - global PickMap
09:19:34.514 - Script 'Workspace.Main', Line 245 - global pickplayers
09:19:34.514 - Script 'Workspace.Main', Line 248
09:19:34.515 - stack

line 92 is: local position = spawns[math.random()].Position
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
04 Mar 2014 08:45 AM
local current = game.Players:FindFirstChild(players[math.random
(1,#players)])
Report Abuse
anth4321 is not online. anth4321
Joined: 22 Sep 2009
Total Posts: 29
04 Mar 2014 09:30 AM
still gives this error:
10:29:50.941 - Workspace.Main:92: attempt to index field '?' (a nil value)
10:29:50.941 - Script 'Workspace.Main', Line 92 - global teleplayers
10:29:50.942 - Script 'Workspace.Main', Line 199 - global PickMap
10:29:50.942 - Script 'Workspace.Main', Line 245 - global pickplayers
10:29:50.943 - Script 'Workspace.Main', Line 248
10:29:50.943 - stack end
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
04 Mar 2014 11:28 AM
Probably because your script is full of errors and you need to learn how tables work.
Report Abuse
Vexedly is not online. Vexedly
Joined: 15 Sep 2006
Total Posts: 7011
04 Mar 2014 11:31 AM
[ Content Deleted ]
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
04 Mar 2014 11:34 AM
spawns =
_G.pickedMap.Spawns:GetChildren()
-- Optimize math.random
math.randomseed(tick())
-- Catch all players
players = game:GetService
("Players"):GetPlayers()
-- Do the following 24 times
for i=1,100 do
-- Function is useless, if the table is
clear
if #players==0 then break end
-- Choose player and Position
local current = game.Players:FindFirstChild(players[math.random(1, #players)])
local position = _G.pickedMap.Spawns:FindFirstChild(spawns[math.random(1, #spawns)]).Position
-- Teleport Players
if current and current.Character then
current.Character:MoveTo
(position)
current.GameStats.Alive.Value = true
end
wait()
end
Report Abuse
anth4321 is not online. anth4321
Joined: 22 Sep 2009
Total Posts: 29
04 Mar 2014 08:12 PM
still doesn't work and the problem is at this line: local position = spawns[math.random()].Position
p.s. I know scripting
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
04 Mar 2014 09:37 PM
I fixed that line, and you obviously don't.
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