Hey! I have recently started scripting, so I decided to learn randoms by creating a label script, but i'm lost. What did I do wrong? If its right, should I move the script/make it a local script? (this is for an intro)
local random = math.random(1,2) while true do if random == 1 then script.Parent.TextLabel.Text = "Test" elseif random == 2 then script.Parent.TextLabel.Text = "Text2" end end
Thanks so much!
if you want the label to continuously change, you will have to put the math.random inside the while True do loop
while true do local random = math.random(1,2) if random == 1 then script.Parent.TextLabel.Text = "Test" elseif random == 2 then script.Parent.TextLabel.Text = "Text2" end end
Explanation
Make a table and use math.random to select a random string from the table.
Code
local words = {"hi", "sup", "testing"} script.Parent.Text = math.random(words)
Edit:I forgot to format my code lol