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: Empty?

Previous Thread :: Next Thread 
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 03:59 PM
What am I doing wrong? Let me explain how it should work. If their are >3 players then their should be a seeker, 1 ghost, and just a normal player (normal players does not need to be chosen). It does not do this. It just gives me the error of the intervals are empty around "table.remove(List, Index2)" here I believe. Please someone help me out! I might not even be doing this right. I've tested this with 3 players. That's how I got the 'intervals are empty' error.

function Start()
List = {}
Seeker = nil
Ghost1Value = nil
Ghost2Value = nil
Ghost3Value = nil
for i,v in pairs(Game.Players:GetPlayers()) do
table.insert(List, v.Name)
if v:FindFirstChild("Chances").Value == true then
table.insert(List, v.Name)
end
local Index1 = math.random(1,#List)
Selected1 = List[Index1]
Noticed.Value = Selected1
Seeker = Selected1
table.remove(List, Index1)
end
for i,v in pairs(Game.Players:GetPlayers()) do
if Game.Players.NumPlayers >= 3 then
if v ~= Seeker then
local Index2 = math.random(1,#List)
Selected2 = List[Index2]
Ghost1.Value = Selected2
Ghost1Value = Selected2
table.remove(List, Index2)--LINE OF ERROR
end
elseif Game.Players.NumPlayers >= 4 then
if v ~= Seeker and v ~= Ghost1Value then
local Index3 = math.random(1,#List)
Selected3 = List[Index3]
Ghost2.Value = Selected3
Ghost2Value = Selected3
table.remove(List, Index3)
end
elseif Game.Players.NumPlayers >= 5 then
if v ~= Seeker and v ~= Ghost1Value and v ~= Ghost2Value then
local Index4 = math.random(1,#List)
Selected4 = List[Index4]
Ghost3.Value = Selected4
Ghost3Value = Selected4
table.remove(List, Index4)
end
end
end
Main()
end
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:01 PM
#List == 0 when math.random is called
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:05 PM
I don't know if I understood correctly:

local Index2 = math.random(1,#List == 0)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:06 PM
No, I'm saying there are 0 values in the List table at the time math.random is called
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:09 PM
Yeah, I know that. I don't know what I'm doing wrong. Am I using table.remove wrong? Please help me.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:09 PM
I'm assuming the first problem is here (if there is more, I haven't checked):

'for i,v in pairs(Game.Players:GetPlayers()) do
table.insert(List, v.Name)
if v:FindFirstChild("Chances").Value == true then
table.insert(List, v.Name)
end
local Index1 = math.random(1,#List)'

At the time this runs, there are probably no players.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:12 PM
Let me explain this a bit more in depth, sorry I did not at first. This works when its my self In an online server. Now, when their are three players it works still with only one player. Their is a 30 second countdown before this script runs, witch gives the player enough time to join the game of course.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:23 PM
???
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:32 PM
Nothing to say? This is just an unsolvable error?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:33 PM
It's too long... But the error is obvious and it's caused by the table "List" being empty.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:35 PM
I know that the error is caused from the list being empty. I just need help with table.insert or table.remove. I have not be told how this could at least be fixed... please it would help a lot.


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:37 PM
Then you might as well do something like this:

if v ~= Seeker and #List > 0 then
local Index2 = math.random(1,#List)
Report Abuse
BloodLitch101 is not online. BloodLitch101
Joined: 13 Jul 2011
Total Posts: 941
23 Aug 2014 04:52 PM
^ do you know what he is asking for? I mean I guess that helps but not what he is needing.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
23 Aug 2014 04:52 PM
When the code in that conditon runs, #list is 0, so if the list is empty just don't run it. I mean if I really wanted to recreate this code I could but that's not what SH is for
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 04:58 PM
This code is the only thing that is stopping me from what i'm trying to develop. Please, if you could. At least give me an example of you re-creation and I'll try and finish it. I would really be thankful.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 05:18 PM
Tell me if this would work. I replaced a lot of values and switched to v.Name instead of v.

function Start()
List = {}
Seeker = nil
for i,v in pairs(Game.Players:GetPlayers()) do
table.insert(List, v.Name)
if v:FindFirstChild("Chances").Value == true then
table.insert(List, v.Name)
end
local Index1 = math.random(1,#List)
Selected1 = List[Index1]
Seeker.Value = Selected1
table.remove(List, Index1)
end
for i,v in pairs(Game.Players:GetPlayers()) do
if v.Name ~= Seeker.Value and #List > 2 then
local Index2 = math.random(1,#List)
Selected2 = List[Index2]
Ghost1.Value = Selected2
table.remove(List, Index2)
end
if v.Name ~= Seeker and v.Name ~= Ghost1.Value and #List > 4 then
local Index3 = math.random(1,#List)
Selected3 = List[Index3]
Ghost2.Value = Selected3
table.remove(List, Index3)
end
if v.Name ~= Seeker and v.Name ~= Ghost1.Value and v ~= Ghost2.Value and #List > 5 then
local Index4 = math.random(1,#List)
Selected4 = List[Index4]
Ghost3.Value = Selected4
table.remove(List, Index4)
end
end
Main()
end
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 05:36 PM
Just verify this and i'll shut up.
Report Abuse
peoplemove12 is not online. peoplemove12
Joined: 11 Feb 2010
Total Posts: 1442
23 Aug 2014 06:35 PM
Bump.
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