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: Question about Tables.

Previous Thread :: Next Thread 
Kirbykid02 is not online. Kirbykid02
Joined: 18 May 2009
Total Posts: 2671
02 Aug 2013 12:07 PM
Say I have a table like this:

example = {1,3,5,6}

--then I genereate a random number from 1 to 10.

num = math.random(1,10)

--Would it be possible to check if that number is in the table without using for, like this:

for i = 1,4 do
if example[i] == num then
--bleh
end end

--And I don't want this either :

if example[1] == num or example[2] == num ,etc
Report Abuse
iIikeyou is not online. iIikeyou
Joined: 07 Mar 2012
Total Posts: 1659
02 Aug 2013 12:10 PM
local start={1,3,5,6}
local finish={}
for _,v in pairs(start)do
finish[v]=true
end

local num=math.random(1,10)
if finish[num]then
--bleh
end
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