Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I get this loop to work?

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

✓ Accepted answer

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

1 comment

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.

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 :)

1 comment

0

The else at line 7 has a problem with the do at line 3. But thank you for the answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.