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 a Frame fade in when I press a TextButton?

How would I make a Frame fade in when I press a TextButton? Thanks.

2 answers

✓ Accepted answer

I'll give you a simple way to do it since you (most likely) aren't familiar with tweening.

local waitTime = 0.5
local value = 0.1
TextButton.MouseButton1Click:Connect(function()
	repeat
		wait(waitTime)
		Frame.BackgroundTransparency -= value
	until
		Frame.BackgroundTransparency == 0
	value *= -1
end)

The time taken for the frame to fade in/out is ~(1 ÷ value) * waitTime. Where ~ is the next highest integer.

I advise you to look at TweenService and how to use it since you can use that to create gradients for anything, such as fading in/out textbuttons or moving them to another position on the screen.

Yes ! if it is a permanently activated button on the player's screen, here is

local Frame = script.Parent.Parent.Frame

script.Parent.MouseButton1Down:Connect(function()
	Frame.Visible = not Frame.Visible
end)

if it is a button of a gui which is not activated permanently, here is

local Frame = script.Parent.Parent.Frame

script.Parent.MouseButton1Down:Connect(function()
	Frame.Visible = true
end)

1 comment

0

This opens and closes the frame, but OP wants it to fade in.

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