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

How do I make looping scrolling text?

Asked by
Loot_O 42
4 years ago

OK, so let me explain; You know on the news, there is this scrolling text that loops? Well I want to try to make that. If you're still don't understand what I'm to make, check this GIF out.

local t = script.Parent
while true do
    t.Text = "AAA     "
    wait(0.05)
    t.Text = " AAA    "
    wait(0.05)
    t.Text = "  AAA   "
    wait(0.05)
    t.Text = "   AAA  "
    wait(0.05)
    t.Text = "    AAA "
    wait(0.05)
    t.Text = "     AAA"
    wait(0.05)
    t.Text = "A     AA"
    wait(0.05)
    t.Text = "AA     A"
    wait(0.05)
end

Now I can make the scrolling text using the code above, but I don't like using it because it takes up too much space; 19 lines is too much! Is there a way to make it taking up less space?

0
I guess you could tween the UI that holds your text instead Spjureeedd 385 — 4y
0
Make sure to enable https://developer.roblox.com/en-us/api-reference/property/GuiObject/ClipsDescendants/index.html then you will be able to use the tween functions User#5423 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Here's whats imo a better approach, it's shorter (9 lines and can be trimmed further but I am sure it's gonna do the job well enough now)

local loopMe = "123456   "
local sLength = string.len(loopMe)
while wait(.05) do
    local newLetter = string.sub(loopMe, sLength, sLength)
    local newString = string.sub(loopMe, 1, sLength-1)
    local Yep_Here = newLetter .. newString
    loopMe = Yep_Here
    print(Yep_Here)
end

Not sure if you need an explanation for this one because you seem advanced enough to understand it. Let me know if you need one.

But basically all it does is take the last letter and make it the first one and so on.

Also, in case whoever is reading this likes making code do a lot while being short, I recommend this: https://codegolf.stackexchange.com/

Ad

Answer this question