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!

5 comments
GUIs are locally situated, meaning Server-sided Scripts (commonly referred to as Regular) wouldn't operate under a UI instance that isn't within a globally shared space, such as workspace. Transfer your code into a LocalScript.
A quick little tip! You're not yielding your loop, which will cause a Script timeout; your Studio will go haywire. Plop a wait() in there while you're at it!
Your logic is also partially incorrect, you statically allocate the random number before running the loop, meaning you'll only determine a random number once, and redundantly set the same Text perpetually.
Move line 1 into the loop.
silence FEAHREN, too many words, let me explain.... ahem.... script.Parent.TextLabel doesn't exist because you aren't crashing.