Nneka
Nneka

Reputation: 37

How do I make math.random print a string

how do you make math.random print a string and not an int value from a table.

this is some of the code I wrote

local Menu = {"🍕","🍟","🍔"}

local Item = math.random(1,#Menu)

print(Item)

Sorry if this is a question if like everyone knows. I just started scripting about 6 days ago. I coudnt find the answer anywhere on google so I decided to come here.

Upvotes: 3

Views: 352

Answers (1)

Paul Kulchenko
Paul Kulchenko

Reputation: 26794

You are close: using print(Menu[Item]) should do what you need.

You can also use math.random(#Menu), as it's the same as math.random(1,#Menu).

Upvotes: 3

Related Questions