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

Why won't my Click Detector fire?

I want to make a thing where if you click the part, a black screen starts to fade in. Then when it is completely faded in(when you can't see anything), you have to wait 3 seconds for you screen to go back to normal. Why is this? (Here is my script)

local qwerty = game.Workspace.Parent.StarterGui.urmommylol.qwerty

script.Parent.ClickDetector.MouseClick:Connect(function()
	while qwerty.BackgroundTransparency > 0 do
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.1
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.2
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.3
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.4
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.5
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.6
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.7
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.8
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 0.9
		wait(0.1)
		qwerty.BackgroundTransparency = qwerty.BackgroundTransparency - 1
		wait(3)
		qwerty.BackgroundTransparency = 1
	end
end)

Thank you!

1 comment

0

Change the local qwerty to "game.StarterGui.urmommylol.qwerty"

1 answer

✓ Accepted answer
script.Parent.MouseClick:Connect(function(player) -- you can get player here
	local gui = player:WaitForChild("PlayerGui").yourscreenguiname.yourframename -- PlayerGui is a folder inside player that have guis

	for i = 1 , 0, -0.1 do -- looping from 1 to 0 by 0.1 so 0.9, 0.8, 0.7 until its 0
		print(i)
		wait(0.1)
		gui.BackgroundTransparency = i -- i means the current for loop value so 0.9,0.8,0.7
	end -- when loop ends, so when number is 0 then script go on
	wait(3)
	gui.BackgroundTransparency = 1
end)

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