Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can you create a math.random and the random number would be inserted in a TextLabel?

Asked by 8 years ago
Edited 8 years ago

I have already created the math.random function and now I would like to know how you can insert that random number into a Textlabel

1 answer

Log in to vote
1
Answered by 8 years ago

I'm not quite sure what you mean. Do you want the TextLabel's text to be only that number, or add on to the existing text?

Here is solution #1 (Making the number the only text):

local num = math.random(1,3)
textLabel.Text = num

Now, if you want to add the number on to text that was already there, this is equally as simple.

local num = math.random(1,3)
textLabel.Text = textLabel.Text..num

By adding the two dots to the end, you are telling the script 'Hey, i want to add more stuff!'

I hope this helped you!

Ad

Answer this question