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

how would i make a button that fades in when i click it and fades out when i click it again?

1 answer

✓ Accepted answer

Do this:

local button = script.Parent
local debounce = false
local faded = false

button.MouseButton1Click:Connect(function()
	if debounce == false then
		debounce = true
		if faded == false then
			faded = true
			for i = 0, 1, 0.05 do
				button.BackGroundTransparency = i
				button.TextTransparency = i
				wait(.05)
				debounce = false
			end
			return -- returning to the begenning of the function to not run the following lines after setting "faded" to true
		    else -- if faded = true
			faded = false
			for i = 1, 0, -0.05 do
				button.BackGroundTransparency = i
				button.TextTransparency = i
				wait(.05)
			end
			debounce = false
		end
	end
end)

This code has to be inserted in a localscript, inside the button you want the player to click.

Hope this helped!

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