Hello. I’m pretty new to Lua and I’ve been tinkering around in studio and making small things. I am trying to make something that prints off a random number onto a gui from two points (e.g 1-100) every two seconds. I’ve been messing around for a bit and looking around and the devforum but I cannot seem to find the problem. Again, I’m pretty new to Lua so I apologize if this sounds like a stupid question. Thanks!
this is what I’ve got so far
local TextLabel = script.Parent
TextLabel.Visible = true
if TextLabel.Visible then
wait (1)
TextLabel.text = (math.random(1,255))
end
As @Miserable_Haven said, you should make a while loop to make a loop that changes something randomly.
code :
local TextLabel = script.Parent
TextLabel.Visible = true
if TextLabel.Visible then
while wait(2) do -- Loop start, this will make the text become random number every 2 seconds.
TextLabel.Text = tostring(math.random(1,255))
end -- If you wanna stop this loop, you should use "break" function to stop
end