I have this script to make a loading screen, and it has a for loop wich sets the imagelabel's imagetransparency from 1 to 0 and then from 0 to 1. The problem is, it waits 0.4 seconds before changing, stops on -0.8, waits about 2 seconds and just doesn't work anymore. This is the script:
local Gui = script:WaitForChild("LoadingGui") local player = game.Players.LocalPlayer local backG = Gui.Back local FranXXicon = backG.Icon wait(6) for i = -1,0,0.1 do wait(0.4) if i == -1 then FranXXicon.ImageTransparency = 1 print(i) elseif i == -0.9 then FranXXicon.ImageTransparency = 0.9 print(i) elseif i == -0.8 then FranXXicon.ImageTransparency = 0.8 print(i) elseif i == -0.7 then FranXXicon.ImageTransparency = 0.7 print(i) elseif i == -0.6 then print(i) FranXXicon.ImageTransparency = 0.6 elseif i == -0.5 then print(i) FranXXicon.ImageTransparency = 0.5 elseif i == -0.4 then print(i) FranXXicon.ImageTransparency = 0.4 elseif i == -0.3 then print(i) FranXXicon.ImageTransparency = 0.3 elseif i == -0.2 then print(i) FranXXicon.ImageTransparency = 0.2 elseif i == -0.1 then print(i) FranXXicon.ImageTransparency = 0.1 elseif i == -1.3877787807814e-16 then print(i) FranXXicon.ImageTransparency = 0 end end for i = 0,1,0.1 do if i == 0.1 then print(i) FranXXicon.ImageTransparency = 0.1 elseif i == 0.2 then print(i) FranXXicon.ImageTransparency = 0.2 elseif i == 0.3 then print(i) FranXXicon.ImageTransparency = 0.3 elseif i == 0.4 then print(i) FranXXicon.ImageTransparency = 0.4 elseif i == 0.5 then print(i) FranXXicon.ImageTransparency = 0.5 elseif i == 0.6 then print(i) FranXXicon.ImageTransparency = 0.6 elseif i == 0.7 then print(i) FranXXicon.ImageTransparency = 0.7 elseif i == 0.8 then print(i) FranXXicon.ImageTransparency = 0.8 elseif i == 0.9 then print(i) FranXXicon.ImageTransparency = 0.9 elseif i == 1 then print(i) FranXXicon.ImageTransparency = 1 end end
I would highly recommend that you use the TweenService to get a smoother change in transparency.
This can be accomplished by doing something like this:
local TweenService = game:GetService("TweenService") local Gui = script:WaitForChild("LoadingGui") local player = game.Players.LocalPlayer local backG = Gui.Back local FranXXicon = backG.Icon local TweenInfo = TweenInfo.new(2) -- Change 2 to how long you want it to take local Tween = TweenService:Create(FranXXicon, TweenInfo, {ImageTransparency = 1}) wait(6) Tween:Play()
A list of properties that can be altered via TweenService can be found here