Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Random table choice?

I have a table but I don't understand how to pick a random number from it, How?

local Table = 
{143737549,
142312040,
}

local Table

5 answers

local Table = 
{143737549,
142312040,
}

Theres your example... without the local Table at the end (not needed)

print(Table[math.random(1,#Table)]) -- Prints a random value in A table

if you want to do stuff with use can use varirables

x = Table[math.random(1,#Table)]
script.Parent.Text = x
local Table = 
{143737549,
142312040,
}

local a = math.random(1,#Table) -- This will select 1 number in table. 
Table = {ur stuff in here}

pickedthings = math.random(1, #Table)
print(pickedthings)

Try this

local Table=
(123456789,104050)

math.Random.Table (123456789,104050)
--do stuff
print ("..number...")

I am a noob at scripting so i don't know if this will work or not.

2 comments

0

If you don't know, don't post.

0

Ok...

table = {123456789,104050}

print(1, #table)

This discussion is preserved as it was. New answers, comments, and votes are closed.