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

2 comments
Fading to black would require changing BackgroundColor3. Or is it already black?
on a click? why are u doin some of this extra work couldnt u just use a for loop