Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Random table choice?

Asked by
NotSoNorm 777 Moderation Voter
10 years ago

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

Log in to vote
2
Answered by
RM0d 305 Moderation Voter
10 years ago
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
Ad
Log in to vote
0
Answered by
lomo0987 250 Moderation Voter
10 years ago
local Table = 
{143737549,
142312040,
}

local a = math.random(1,#Table) -- This will select 1 number in table. 
Log in to vote
0
Answered by
KAAK82 16
10 years ago
Table = {ur stuff in here}

pickedthings = math.random(1, #Table)
print(pickedthings)
Log in to vote
-1
Answered by 10 years ago

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.

0
If you don't know, don't post. Azarth 3141 — 10y
0
Ok... iluvmaths1123 198 — 10y
Log in to vote
-1
Answered by 10 years ago
table = {123456789,104050}

print(1, #table)

Answer this question