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: Can't find a variable I just defined?

Previous Thread :: Next Thread 
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
22 Jun 2014 01:56 PM
For some reason it says it can't find "enemies" but yet I have defined it just a few lines above. What is wrong here?

Enemies = {"Troll"},{"Cursed Boar"},{"Orc"},{"Cave Troll"}
--SELECT A RANDOM ENEMY
function get_table(Enemies)
random_item= Enemies[math.random(1,#Enemies)]
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
22 Jun 2014 01:58 PM
Because you overrided the variable with the argument 'Enemies' in get_table's parameters.
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
22 Jun 2014 02:00 PM
Enemies = {["Troll"],["Cursed Boar"],["Orc"],["Cave Troll"]}
function get_random(Table)
return Table[math.random(1,#Table)]
end
print(get_random(Enemies))
Report Abuse
Typocrite is not online. Typocrite
Joined: 28 Aug 2013
Total Posts: 6856
22 Jun 2014 02:00 PM
Oh. Hmm. Removed it and it fixed. 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