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

Anybody know why this Fading Gui Script isn't working?

Any help?

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

4 comments

0

Is it a localscript? Is it disabled? What kind of gui is it, for a ScreenGui, or a SurfaceGui?

0

also use a for loop

0

Yeah, really

0

Tansparency....

2 answers

There's a typo and please Use a for loop

for i=1,0,-0.1 do
	script.Parent.BackgroundTransparency = i
end

Its simple, you can use a for loop(generic loop) and a wait(0.1)

Wait is for loop?

The for loop is a way of running a command or set of commands a set number of times. The basic syntax is as following:

How to use for loop?

for iterator_variable = start value , end value , increment do

(this is in wiki)

examples:

-- 1
for i = 1, 5 do   	
    print("Hello Mom!") -- Print Hello Mom 5 times
end

-- 2
for i = 10, 1, -1 do   	
    print(i) -- print number with start value 10 to 1: removing 1
end

-- 3
for i = 1, 10, 0.5 do   	
    print(i) -- print number with start value 1 to 10: removing 0.5
end

Here is fixed script:

for i=1,0,-0.1 do -- value with 1 to 0: removing 0.1 until value not 0
	script.Parent.BackgroundTransparency = i -- set the transparency
	wait(0.1) -- Simple wait to have a delay when changing the transparency
end

Wiki pages:

For loop

Wait

Hope it helped :D

1 comment

0

you can also use tweenservice for a much more cleaner effect and not as limited as using a numeric for

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