How can i make a TextLabel display a random word?

Title says it all.


3 Likes

Like picking random text from table?

local words = {"apple","chocolate","battery"} --You can add more words but it should be a string
local label = path_to_textlabel

label.Text = words[math.random(1,#words)]

Or totally random word like this: mfESl1jQIYHI*WX?

local label = path_to_textlabel

label.Text = ""

for i = 0,5,1 do -- You can set how long the word it should be

label.Text = label.Text .. string.char(math.random(32,126))

end

Here is the String.char() documentation:

https://developer.roblox.com/en-us/api-reference/lua-docs/string

And here is the ASCII map:

[EDIT:] I forgot to write, but you have to add filter function to this code, because this code able to produce Inappropriative words.

20 Likes