How to do a random TextLabel from a table?

How could i do a random Text from a table? :frowning: help please, what am i doing wrong?

   local Texts = {[script.Parent.HitsVar.Text] = "sd",[script.Parent.HitsVar.Text] = "kaka"}
    			math.random(Texts)
    			print(Texts)

image

You could do this:

local text = { -- array containing random text
    "text1",
    "hello world!"
}

local textLabel = -- text label here

textLabel.Text = text[math.random(1, #text)] -- change the text to something random in the array
1 Like

Hm, if you needed to store a table inside a string, you would have to use HTTPService:JSONEncode() and JSONDecode()

Else @HugeCoolboy2007 works as it should;

1 Like

Oh thanks you!! :smiley: it works