如何让 math.random 打印一个字符串

How do I make math.random print a string

如何让 math.random 打印一个字符串 而不是来自 table.

的 int 值

这是我写的一些代码

local Menu = {"","",""}

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

print(Item)

抱歉,如果这是一个众所周知的问题。我大约 6 天前才开始编写脚本。我在 google 上的任何地方都找不到答案,所以我决定来这里。

你很接近:使用 print(Menu[Item]) 应该可以满足你的需要。

您也可以使用 math.random(#Menu),因为它与 math.random(1,#Menu) 相同。