output: 20:40:25.927 - Workspace.Script (1, 14): Expected identifier, got '='
local Randomizer = {} Randomizer{1} = "Gun" Randomizer{2} = "Knife" Randomizer{3} = "DeathMatch" print(math.random(1, 3))
So, two things.
To index a table, along with giving it a value, you use []s, and you're using {}s.
local foo={} foo[1]="Hello." foo[2]="I'm in a table" foo[3]=3+5 --...
Second, I'm guessing you want to print a random value in that table, and you're doing well so far. The thing you're missing is that you're just printing a random value, instead of getting the thing in that position in the table.
In your example, that'd go like so.
local Randomizer = {} Randomizer{1} = "Gun" Randomizer{2} = "Knife" Randomizer{3} = "DeathMatch" print(Randomizer[math.random(1, 3)]) --Alternatively, you can do something in this style, it's the same result. local randomNumber=math.random(1, 3) print(Randomizer[randomNumber]) --Or like so local randomNumber=math.random(1, #Randomizer) --#Table gives you the length of a table print(Randomizer[randomNumber]) --...So on
Why wont this work?
local Randomizer = {} Randomizer[1] = "Gun" Randomizer[2] = "Knife" Randomizer[3] = "DeathMatch" print(math.random(1, 3)) if Randomizer == 2 then print("Works All Right!") end