I found this script that pretty much adds a fade like effect when you either spawn or die, but how would i make it so it fades to black, and then back to transparent when i click a TextButton?
script:
fade = script.Parent fadeGoal = 0 fadeRate = 0.01 function updateFade() local current = fade.BackgroundTransparency if current < fadeGoal then fade.BackgroundTransparency = math.min(fadeGoal,current+fadeRate) elseif current > fadeGoal then fade.BackgroundTransparency = math.max(fadeGoal,current-fadeRate) else fade.BackgroundTransparency = fadeGoal end end player = game.Players.LocalPlayer character = player.Character or player.CharacterAdded:wait() humanoid = player.Character:WaitForChild("Humanoid") rs = game:GetService("RunService") fadeGoal = 1 humanoid.Died:connect(function () wait(1) fadeGoal = 0 player.CharacterAdded:wait() fadeGoal = 1 end) rs.RenderStepped:connect(updateFade) fade.Visible = true
script.Parent.MouseButton1Click:Connect(function() if script.Parent.Parent.RebirthFrame.Visible = true the script.Parent.Parent.RebirthFrame.Visible == false end end)
Here if it works mark it!
I hope you already solved this but I guess just in case...all you need is a simple for loop
To achieve this effect, make the ui element black and set its transparency to 1. The for loop will then smoothly make the ui element visible.
local ui = script.Parent for i = 1,0,-.1 do-- fade to black ui.Transparency = i wait() end
to do the opposite(fade away)
local ui = script.Parent for i = 0,1 do-- fade to black ui.Transparency = i wait() end
If you don't understand how for loops work here is some documentation. https://developer.roblox.com/en-us/articles/For-Loops
To connect this to a button
local debounce = false script.Parent.MouseButton1Click:Connect(function()--script.Parent would be the button if debounce == false then debounce = true --fadeblackelement is whatever the gui element that your wanting to fade is local fadeblackelement = script.Parent.Parent.FadeBlack if fadeblackelement.Transparency > .5 then for i = fadeblackelement.Transparency ,0,-.1 do--set opaque fadeblackelement.Transparency = i wait() end else for i = fadeblackelement.Transparency ,1,.1 do--set transparent fadeblackelement.Transparency = i wait() end end debounce = false end end)