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

How do I get this loop to work?

Asked by
Ripik 5
9 years ago

Hello, I wanted to make it so that the baseplate would appear with a slight delay, I have tried this:

parent = game.workspace.Baseplate


parent.Transparency = -0.001
wait (0.01)
repeat until parent.Transparency == 0

But this crashed the studio, but when I tried this:

parent = game.workspace.Baseplate


parent.Transparency = -0.001
wait (0.01)
repeat until parent.Transparency < 0.001

That does it instantaneously.

How do I do this with a delay between each decrease in the transparency, and have it stop when the block is solid?

Thank You In Advance.

2 answers

Log in to vote
0
Answered by 9 years ago

You had the right idea, you just ordered your code incorrectly.

local parent = workspace.Baseplate

repeat --Repeat starts the loop
parent.Transparency = -0.001
wait (0.01)
until parent.Transparency == 0 -- until closes the loop with a conditional
0
Is it possible to delay how fast it decreases? Because when I put it in studio, it becomes completely visible instantly. But still, Thank you for the answer. Ripik 5 — 9y
Ad
Log in to vote
0
Answered by 9 years ago
parent = game.Workspace.BasePlate

while true do
    if parent.Transparency == 0 then
        script.Disabled = true
    else
        parent.Transparency = parent.Transparency - 1
    end
end

Tell me if this doesn't work :)

0
The else at line 7 has a problem with the do at line 3. But thank you for the answer. Ripik 5 — 9y

Answer this question