I want my script to choose a random table. Is there a way to do it using for example math.random?
-- This is an example script
local table1 = {1,2,10}
local table2 = {5,11,0}
local randomTable = --Choose random table
print(randomTable)
I want my script to choose a random table. Is there a way to do it using for example math.random?
-- This is an example script
local table1 = {1,2,10}
local table2 = {5,11,0}
local randomTable = --Choose random table
print(randomTable)
local randomtable
local table1 = {1,2,10}
local table2 = {5,11,0}
local random = math.random(1,2)
if random == 1 then
randomtable = table1
else
randomtable = table2
end
print(randomTable)
Is there a specific function to choose between tables or do I have to use if statements?
You have to use if statements,but i see nothing wrong wth it
It isn’t required to use if statements.
Instead you could use 1 larger table that has multiple tables within it and then randomly chose one like so:
local Table = {
{1,2,10},
{5,11,0}
}
local RandomTable = Table[math.random(1, 2)]
print(RandomTable)
That way works 100%, but there are other methods you can use that are better for optimization and to look better, etc.
Really what is it? I wanna learn since i do feel like there are more ways but idk what is it
Thank you. That’s what I needed
What kind of level of a scripter are you so I can help you understand a new method of optimization.
idk but does it really matter, just teach lol
Well some methods are for more advanced scripters who have learnt, you need to learn at your skill level or it won’t make sense…
well i have been learning for about a year
So you’re starting to learn intermediate scripting?
kinda but idk how i guess i just try to script and learn more stuff
Add my discord WarfulAres#9158 we’ll talk there
I dont use discord though can we just private chat
yeah sure go to the private chat