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

A Long Script Into A Short Script?

Asked by 9 years ago

Hello there! I have a really long script and I want to make it to a short script. As I know it is called a loop? I am still learning LUA and don't know how to do it. Here is the script:

M = Instance.new("Message")
M.Parent = game.Workspace
M.Text = "L"
wait(0.1)
M.Text = "1"
wait(0.1)
M.Text = "2"
wait(0.1)
M.Text = "3"
wait(0.1)
M.Text = "4"
wait(0.1)
M.Text = "5"
wait(0.1)
M.Text = "6 "
wait(0.1)
M.Text = "7"
wait(0.1)
M.Text = "8"
wait(0.1)
M.Text = "9"
wait(0.1)
M.Text = "10"
wait(1)
M.Text = ""
x.Parent = game.Workspace
wait(3)
M:Remove()

How do I make it really short?

1 answer

Log in to vote
1
Answered by 9 years ago

You can use a for loop, just as you mentioned!

m = Instance.new("Message",workspace)
m.Text = "L"
for i = 1,10 do
    wait(.1)
    m.Text = i
end
wait(1)
m.Text = ""
wait(3)
m:Destroy()

Learn more here:

http://wiki.roblox.com/index.php?title=Loops

Ad

Answer this question