*This is a script to make a gui object (frame) fade in their transparency very smoothly, smoother than a simple loop.
.....But the kicker is that the fade only works when your player dies or respawns. When the player dies the screen fades into a black frame, when the player respawns the black frame fades away.
I want it work so It works only on wait time and not on humnoid.died function.
I want It to control this script on will is what i'm saying instead of it being activated only when the player character dies.
--potatoboy99990 was able to to explain how this script works perfectly, but the next step is I to find out a way, which I do not know to how, to reverse engineer this script so it'll work on wait time. fade = script.Parent --The gui fadeGoal = 0 -- What the transparency should end at. This is 0 so it is fading in. fadeRate = 0.05 -- How fast it should fade function updateFade() local current = fade.BackgroundTransparency --The background if current < fadeGoal then --If the current transparency is smaller that the the goal fade.BackgroundTransparency = math.min(fadeGoal,current+fadeRate) -- If true add the current transparency from the fade rate elseif current > fadeGoal then fade.BackgroundTransparency = math.max(fadeGoal,current-fadeRate) --If true subtract the current transparency from the fade rate else fade.BackgroundTransparency = fadeGoal -- if the transparency is equel to or bigger than goal sets transparency to goal 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 () --Screen fades smoothly into a black frame when the player character dies. wait(1) fadeGoal = 0 player.CharacterAdded:wait() --The black frame fades away smoothly when the player character respawns. fadeGoal = 1 end) rs.RenderStepped:connect(updateFade) fade.Visible = true
My first attempt at reverse engineering. Somebody please throw this into a localscript of an imagelabel in studio and see why it doesn't work.
local fade = script.Parent local ChangeRate = 0.01 local ChangeGoal = 0 function updateFade() local current = frame.ImageTransparency if current < FadeGoal then fade.ImageTransparency = math.min(ChangeGoal,current+ChangeRate) elseif current > FadeGoal then fade.ImageTransparency = math.max(ChangeGoal,current-ChangeRate) else fade.ImageTransparency = ChangeGoal end end while true do --For some reason the FadeGoal only activates with a coroutine and not with a while do loop, but why? ChangeGoal = 1 wait(1) ChangeGoal = 0 end) rs.RenderStepped:connect(updateFade) fade.Visible = true
.