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

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

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?

1 comment

0

Use a 'for loop'. They are less messy, look more professional :3, and are more efficient.

3 answers

✓ Accepted answer

the end should be

Curtain.ClickDetector.MouseClick:connect(OnClicked)

1 comment

0

Oh thanks i meant to do that but i guess i forgot

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

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.

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