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

How would I shorten this?

How would I shorten this script?

	script.Parent.BlackScreen.BackgroundTransparency = 0.1
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.2
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.3
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.4
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.5
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.6
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.7
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.8
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 0.9
	wait(0.1)
	script.Parent.BlackScreen.BackgroundTransparency = 1	

3 answers

You can use a numerical for loop like so:

local blackScreen = script.Parent.BlackScreen; -- Create a reference to the GUIObject
for i = 0.1, 1, 0.1 do -- Start at 0.1, finish at 1, increase i by 0.1 every iteration
	blackScreen.BackgroundTransparency = i; -- Se the property to whatever I equals
	wait(0.1);
end

By using a for loop to increase the transparency (Sorry if script didn't work);

for i = 1, 0, 0.1 do --Heres our four loop
script.Parent.BlackScreen.BackgroundTransparency = i --There is where 'i' will come in
wait(0.1) --Will wait each 0.10 milliseconds
end --The end to end the `for` loop code

Hope this helped!

1 comment

0

It should be 0, 1. It's start, end [, increment] and 100 milliseconds, not 0.1 milliseconds

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