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

Can you help me with my Fade In/Fade Out GUI script?

Asked by 9 years ago

This is it:

StarterGui>IntroGui>BlackFrame>Script

This is the code:

StarterGui > IntroGui > BlackFrame > Script

intro = game.StarterGui

intro = game.StarterGui

function gameIntro()
    if intro.IntroGui.BlackFrame.BackgroundTransparency == 0 then
        intro.IntroGui.BlackFrame.BackgroundTransparency = .1
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .2
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .3
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .4
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .5
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .6
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .7
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .8
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .9
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = 1
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .9
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .8
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .7
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .6
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .5
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .4
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .3
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .2
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = .1
        wait(1)
        intro.IntroGui.BlackFrame.BackgroundTransparency = 0
    end
end

The frame isn't fading in/out.

Someone help me please?

0
Please accept the answer you feel helped you. Just click " Accept answer" Perci1 4988 — 9y

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

You have two problems that will prevent your code from working.


The first problem is that it will never run!

Functions only run when they are called, or, if they're connected to an event, when an event is triggered.

To call a function, simply use its name followed by parentheses. To connect it to an event, just access the event then use the connect method.

--Will NEVER EVER run
function myFunction()
    print("Hello world!")
end
--Will run when the game starts
function myFunction()
    print("Hello world!")
end
myFunction()
--Will run when script.Parent is touched.
function myFunction()
    print("Hello world!")
end
script.Parent.Touched:connect(myFunction)

Since I don't know when you want your code to run, I can't give you any advice there. But as is, it will never run at all.



Your second problem is that you're making all your edits in StarterGui. This mistake is very common. StarterGui is not what a player sees! It is simply a container to store GUIs that will later be cloned into a Player's PlayerGui. You can only see GUIs parented to StarterGui in studio for testing purposes.

Assuming this script is already inside the GUI, you can just use script.Parent. Since the gui will be cloned into PlayerGui before the code can run, the edits it makes will be visible.



Your third problem is simply an efficiency error. Instead of that huge blob of code, just use a for loop.

--Invisible
for i = 0, 1, 0.1 do --That is, startNumber, endNumber, increment
    wait(1)
    script.Parent.BackgroundTransparency = i
end

--Visible
for i = 1, 0, -0.1 do
    wait(1)
    script.Parent.BackgroundTransparency = i
end
0
OMG THANK YOU SO MUCH IT WORKED! <3 <3 <3 <3 SoarinApple 0 — 9y
Ad

Answer this question