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

How do I make this fade away and fade in again?

Asked by 10 years ago

Curtain = game.Workspace.Curtain

function onClicked()

Curtain.Transparency.new = 0.1

Curtain.Transparency.new = 0.2

Curtain.Transparency.new = 0.3

Curtain.Transparency.new = 0.4

Curtain.Transparency.new = 0.5

Curtain.Transparency.new = 0.6

Curtain.Transparency.new = 0.7

Curtain.Transparency.new = 0.8

Curtain.Transparency.new = 0.9

Curtain.Transparency.new = 1

wait(3)

Curtain.Transparency.new = 0.9

Curtain.Transparency.new = 0.8

Curtain.Transparency.new = 0.7

Curtain.Transparency.new = 0.6

Curtain.Transparency.new = 0.5

Curtain.Transparency.new = 0.4

Curtain.Transparency.new = 0.3

Curtain.Transparency.new = 0.2

Curtain.Transparency.new = 0.1

Curtain.Transparency.new = 0

end

Curtain.ClickDetector.MouseClick:connect()

I'm building the new Roblox Got Talent place for this winters show and I'm having problems with making the curtain fade away and after 3 seconds I want it to fade back in again. What am I doing wrong?

0
Use a 'for loop'. They are less messy, look more professional :3, and are more efficient. raystriker6707 30 — 10y

3 answers

Log in to vote
0
Answered by
parkderp1 105
10 years ago

the end should be

Curtain.ClickDetector.MouseClick:connect(OnClicked)

0
Oh thanks i meant to do that but i guess i forgot FastSnail5 8 — 10y
Ad
Log in to vote
0
Answered by
0ea 0
10 years ago

You could add a for loop to it instead of making loads of lines

Log in to vote
0
Answered by
Redbullusa 1580 Moderation Voter
10 years ago

For the sake of efficiency, you could use a "for" loop instead:

Curtain = game.Workspace.Curtain

function onClicked()
    for i = 1,10 do
        Curtain.Transparency = Curtain.Transparency + .1
        wait(.25)               -- This could be too fast.
    end
    Curtain.Transparency = 1                --Makes sure it is invisible.
    wait(3)
    for i = 1,10 do
        Curtain.Transparency = Curtain.Transparency - .1
        wait(.25)               -- This could be too fast.
    end
    Curtain.Transparency = 0                --Makes sure it is visible.
end

Curtain.ClickDetector.MouseClick:connect(onClicked)

Plus, your code doesn't have any wait times in between each line, so it's going to all run at the same time (the parts before "wait(3)" and after), meaning when it is clicked, the Curtain will be invisible for 3 seconds, then become visible. It won't undergo transition.

Answer this question