Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this work?

Asked by 7 years ago

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
0
First, do you know how to use for loops? GoldenPhysics 474 — 7y
0
Yes FederalJustice 35 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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
Ad

Answer this question