So I don’t normally script things but recently I’ve been trying to learn some new things to help me later on down the road. I recently was making a machine with some gizmos and gadgets on it and I figured I’d add a text box with random numbers appearing every One second. I know how to do the bare minimum and print the numbers to the output tab, but I don’t know how to apply it to a a text box.
As I’m sure a lot of you can tell, this is the script that randomly prints numbers to the output tab every second out of a possible 1 in 1000 numbers
While true do
wait (1)
print(math.random(1,1000))
end
Something like this is essentially what I’m trying to accomplish
local textLabel = game:GetService("StarterGui").ScreenGui.Frame.TextLabel
while wait(1) do
local textYouWant = math.random(1, 1000)
textLabel.Text = tostring(textYouWant)
end
This is right but just put the “textYouWant” variable in the while loop so there is a different number each time it loops through the while loop, instead of one random number picked when the script is executed.
but if you really want to make it like what you want with the gif, try to make a delay and make the text transparency or color, depends on how you want to do it, using the object’s name and TextTransparency.
I know this is a stupid question but, I’m not sure how exactly to set this up in the actual brick. I put a brick down, then a SurfaceGui, inside it I put a TextLabel. Where do I put the script to make numbers appear because, (and again stupid question), I cant write every number 1-1000 in the text label.
that’s the variable that’s going to hold the random values, don’t delete it or else you would end up with an error that won’t know what the variable is when it’s attempted to be used.
I went back and played around with it, and I realized that as long as there’s literally anything in that space, it’ll work. Knowing that, I changed “textYouWant” to “spaghetti”!
It’s won’t work as your only changing StarterGui (the template of the UI), maybe try:
local Client = game:GetService("Players").LocalPlayer
while wait(1) do
local numberText = math.random(1, 1000)
local changeText = Client.PlayerGui.ScreenGui.Frame.yourtextnamehere
changeText.Text = tostring(numberText)
wait(0.5)
print("Okay! This got debugged! (1)")
end
end)