I'm trying to make the background of the gui keep transitioning from being visible to being transparent, this is what I have thought of so far.
BetaPassNeededGui = script.Parent Up = false BetaPassNeededGui.BackgroundTransparency = 0 while true do print("Script Active") wait() while Up == true do print("Mode = ".. Up) while BetaPassNeededGui.BackgroundTransparency <= 1 do BetaPassNeededGui.BackgroundTransparency = BetaPassNeededGui.BackgroundTransparency + 0.1 wait(0.1) if BetaPassNeededGui.BackgroundTransparency == 1 then Up = false end end while Up == false do print("Mode = ".. Up) while BetaPassNeededGui.BackgroundTransparency >= 0 do BetaPassNeededGui.BackgroundTransparency = BetaPassNeededGui.BackgroundTransparency - 0.1 wait(0.1) if BetaPassNeededGui.BackgroundTransparency == 0 then Up = true end end end end
I think that tweening is a much cleaner way to achieve what you want. If you want to change how long it takes for the transparency to change, modify the ChangeTime
variable.
local ChangeTime = 1 -- Time in seconds local twn local BGui = script.Parent local t = game:GetService("TweenService") BGui.Transparency = 0 while BGui.Visible do twn = t:Create(BGui, TweenInfo.new(ChangeTime, Enum.EasingStyle.Linear), {Transparency = 1}) twn:Play() twn.Completed:Wait() twn = t:Create(BGui, TweenInfo.new(ChangeTime, Enum.EasingStyle.Linear), {Transparency = 0}) twn:Play() twn.Completed:Wait() twn = nil wait() end
If my answer helped you please make sure to mark it as correct!