This is my first time making a Intro UI. What did I do wrong
--//FederalJustice\\-- ----------------- --//Variables\\-- ----------------- local Logo = script.Parent.Logo local Credit = script.Parent.Credit --------------------- --//Main Function\\-- --------------------- game.Players.PlayerAdded:connect(function() Credit:TweenPosition(UDim2.new(0.5, -200, 0.5, 100), 'Out', 'Quad', 2) wait(2) Fade() end) ------------------------------------- --//Upcoming Logo Fading Function\\-- ------------------------------------- function Fade() Logo.ImageTransparency = 1 wait(0.1) Logo.ImageTransparency = 0.9 wait(0.1) Logo.ImageTransparency = 0.8 wait(0.1) Logo.ImageTransparency = 0.7 wait(0.1) Logo.ImageTransparency = 0.6 wait(0.1) Logo.ImageTransparency = 0.5 wait(0.1) Logo.ImageTransparency = 0.4 wait(0.1) Logo.ImageTransparency = 0.3 wait(0.1) Logo.ImageTransparency = 0.2 wait(0.1) Logo.ImageTransparency = 0.1 wait(0.1) Logo.ImageTransparency = 0 end if Logo.ImageTransparency == 0 and Credit.Position == UDim2.new(0.5, -200, 0.5, 100)then script.Parent.Visible = false wait(1) script:Destroy() end
Use for loops
to keep the amount of lines in your code shorter. With the for loop;
function Fade() for 1=1,0,.1 do --starting at 1, going to 0, counting by .1 Logo.ImageTransparency=i wait(.1) end end
An easy way to check if the Tween is done is with TweenStatus
, shown here;
local finished game.Players.PlayerAdded:connect(function() Credit:TweenPosition(UDim2.new(0.5, -200, 0.5, 100), 'Out', 'Quad', 2,false,function() finished=true end) wait(2) Fade() end) ---------------------------------------------- if Logo.ImageTransparency == 0 and finished then script.Parent.Visible = false wait(1) script:Destroy() end