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

How can I set this loop to alternate a brick's transparency?

Asked by
gobrett 11
4 years ago
Edited 4 years ago

I want the brick "Eyelid1" to alternate between transparency 1 and 0 every (0.5) seconds endlessly in a loop. Where am I going wrong? Also note, I put "Eyelid1" in a folder named "Eyelid".

while true do
game.Workspace.Eyelid.Eyelid1.Transparency = 1
wait(0.5)
game.Workspace.Eyelid.Eyelid1.Transparency = 0
end

3 answers

Log in to vote
0
Answered by
3wdo 198
4 years ago
local part = script.Parent

while true do
    part.Transparency = 1
    wait(0.5)
    part.Transparency = 0
    wait(0.5) -- this makes it so it can start over
end
0
Thank you so much! I'll have to get better at my structure. :) gobrett 11 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local part=--your part
while true do
if part.Transparency==0 then
part.Transparency=1


else

part.Transparency=0


end



wait(0.5)
end
0
Workspace.Eyelid.Eyelid1.Script:3: 'then' expected near '=' gobrett 11 — 4y
0
oops EmbeddedHorror 299 — 4y
0
there try it now EmbeddedHorror 299 — 4y
0
there try it now EmbeddedHorror 299 — 4y
Log in to vote
0
Answered by
proo34 41
4 years ago

If you want the eyes to close more smoothly, then you can use a for i loop.

while true do
for i = 1, 20 do
game.Workspace.Eyelid.Eyelid1.Transparency - 0.05
wait(0.02)
end

for i = 1, 20 do
game.Workspace.Eyelid.Eyelid1.Transparency + 0.05
wait(0.02)
end
end

Answer this question