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
 

Re: bad argument #2 to 'random' (interval is empty)

Previous Thread :: Next Thread 
jbjgang2 is not online. jbjgang2
Joined: 07 Feb 2010
Total Posts: 8948
11 Jan 2015 01:21 PM
local suspects = PossibleVictims[math.random(1,#PossibleVictims)]

PossibleVictims is an array of 5 random plyers

Swaggin' Since Twenty Ten
Report Abuse
jbjgang2 is not online. jbjgang2
Joined: 07 Feb 2010
Total Posts: 8948
11 Jan 2015 01:22 PM
I fixed it nvm
changed 1 to 0

Swaggin' Since Twenty Ten
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2015 01:32 PM
That's going to b a problem, it'll be nil since PossibleVictims[0] is most likely nil (unless you set it to something directly).

The problem is that when that part of the script runs, PossibleVictims contains nothing.
Report Abuse
jbjgang2 is not online. jbjgang2
Joined: 07 Feb 2010
Total Posts: 8948
11 Jan 2015 01:41 PM
but when I change 0 back to 1, the script doesnt work again

Swaggin' Since Twenty Ten
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
11 Jan 2015 01:45 PM
'The problem is that when that part of the script runs, PossibleVictims contains nothing.'

You might think it contains 5, but it doesn't (or at least not in the sense that the key starts at 1 and ascends to 5+)
Report Abuse
jbjgang2 is not online. jbjgang2
Joined: 07 Feb 2010
Total Posts: 8948
11 Jan 2015 01:46 PM

Spaces = 5
local name = Names[math.random(1,#Names)]
local suspects = PossibleVictims[math.random(0,#PossibleVictims)]
nametext.Text = name
table.remove(Names, Names[name])
if player ~= witch then
if Spaces >= 1 then
table.insert(PossibleVictims, Names[name])
Spaces = Spaces - 1
end
end
if player == witch then
if Spaces >= 1 then
Spaces = Spaces - 1
table.insert(PossibleVictims, Names[name])
else
table.remove(PossibleVictims, PossibleVictims[suspects])
table.insert(PossibleVictims, Names[name])
end
end
end

Swaggin' Since Twenty Ten
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