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

Is there another way to do loop this transparency?

I write a command about transparency, but I want to loop it, I knew how to, but I kind of forget, I remember it's like "for i" something like, so can anyone help me remember?

while true do
	script.Parent.Transparency = 0.1
	wait(1.5)
	script.Parent.Transparency = 0.2
	wait(1.5)
	script.Parent.Transparency = 0.3
	wait(1.5)
	script.Parent.Transparency = 0.4
	wait(1.5)
	script.Parent.Transparency = 0.5
	wait(1.5)
	script.Parent.Transparency = 0.6
	wait(1.5)
	script.Parent.Transparency = 0.7
	wait(1.5)
	script.Parent.Transparency = 0.8
	wait(1.5)
	script.Parent.Transparency = 0.9
	wait(1.5)
	script.Parent.Transparency = 1
end

I can just do that but I think there is a easier way!

4 answers

✓ Accepted answer

Yes you are correct, there is an easier way.

for i = 1,10 do
	script.Parent.Transparency = script.Parent.Transparency + 0.1
	wait(1.5)
end

If you want it looped it would be...

while true do
	for i = 1,10 do
		script.Parent.Transparency = script.Parent.Transparency + 0.1
		wait(1.5)
	end

	for i = 1,10 do
		script.Parent.Transparency = script.Parent.Transparency - 0.1
		wait(1.5)
	end
end

Helpful Link: http://robloxdev.com/articles/Roblox-Coding-Basics-Loops#For

2 comments

0

XxxLloyd061302xxX's answer is probably better in terms of changing the transparency though.

0

XxxLloyd061302xxX doesnt make his own scripts, he copies other peoples scripts and makes them into his video tutorial.

Use for loop.


for i = 0,1, 0.1 do
	wait()
	script.Parent.Transparency = i
end

Just like that. 0.1, is the increment of the transparency.

1 comment

0

thank you so much for reminding me! tysm!

for loop = 1,10 do
	wait()
	script.Parent.Transparency = loop/10
end

If you're trying to loop a particle emitter transparency, look into "NumberSequence".

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