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

Am I doing something wrong with visual disambiguation?

Asked by 8 years ago

So I am wanting the text label and imagelabel to fade out after 5 seconds of staying up. There is a function on line 25-27 that makes the function after end when the song is over. Here is the currect script-

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui

local textLabel = Instance.new("TextLabel")
textLabel.Parent = screen
textLabel.Text = "Welcome to the City of bloxbury"
textLabel.Size = UDim2.new(1,0,1,0)
textLabel.FontSize = Enum.FontSize.Size14
textLabel.Font = Enum.Font.SourceSansLight

local imageLabel = Instance.new("ImageLabel")
imageLabel.Parent = screen
imageLabel.Size = UDim2.new(1,0,1,0)
imageLabel.Image = "http://www.roblox.com/asset?id=365763888"

local sound = Instance.new("Sound", PlayerGui)
sound.SoundId = "http://www.roblox.com/asset/?id=334321597"
sound:play(120)

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

sound.Ended:connect(function()
    screen:destroy()
end)

local count = 0
local start = tick ()
while tick(60)- start < 6 do
    textLabel.Text = "Welcome to the City of bloxbury"
    textLabel.Size = UDim2.new(1,0,0.25,0)
    textLabel.FontSize = Enum.FontSize.Size48
    textLabel.Font = Enum.Font.SourceSansLight
    textLabel.Position = UDim2.new(0.0,0.5,0.0)
    textLabel.TextColor3 = Color3.new(255,255,255)
    imageLabel.Size = UDim2.new(1,0,1,0)
    imageLabel.Image = "http://www.roblox.com/asset/?id=365763888"
    wait (5)
    i = 0, 1, .1 do 
        textLabel.Transparency = i 
        imageLabel.Transparency = i 
        wait(.1)
        visible = false 
        end
end

Lines 41-46 is the function that I was told to use for them to disambiguate. And Line 40 is my attempt to apply a wait time so that it would wait for 5 seconds before fading out. If it helps, I planning on having it fade out at the beginning rather than the end. But I think it fades a bit a the end rather the beginning.

Thank you :)

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

Your for loop as a few issues.

local PlayerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
PlayerGui:SetTopbarTransparency(0)

local screen = Instance.new("ScreenGui")
screen.Parent = PlayerGui

local textLabel = Instance.new("TextLabel")
textLabel.Parent = screen
textLabel.Text = "Welcome to the City of bloxbury"
textLabel.Size = UDim2.new(1,0,1,0)
textLabel.FontSize = Enum.FontSize.Size14
textLabel.Font = Enum.Font.SourceSansLight

local imageLabel = Instance.new("ImageLabel")
imageLabel.Parent = screen
imageLabel.Size = UDim2.new(1,0,1,0)
imageLabel.Image = "http://www.roblox.com/asset?id=365763888"

local sound = Instance.new("Sound", PlayerGui)
sound.SoundId = "http://www.roblox.com/asset/?id=334321597"
sound:play(120)

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

sound.Ended:connect(function()
    screen:destroy()
end)

local count = 0
local start = tick ()
while tick(60)- start < 6 do -- The point of this loop is to wait for the game to be loaded, so you can put the fade after it.
    textLabel.Text = "Welcome to the City of bloxbury"
    textLabel.Size = UDim2.new(1,0,0.25,0)
    textLabel.FontSize = Enum.FontSize.Size48
    textLabel.Font = Enum.Font.SourceSansLight
    textLabel.Position = UDim2.new(0.0,0.5,0.0)
    textLabel.TextColor3 = Color3.new(255,255,255)
    imageLabel.Size = UDim2.new(1,0,1,0)
    imageLabel.Image = "http://www.roblox.com/asset/?id=365763888"
end
    wait (5) -- You could remove this, if you please.
    for i = 0, 1, .1 do 
            textLabel.Transparency = i 
            imageLabel.Transparency = i 
            wait(.1)
    end
    textLabel.Visible = false -- You have to set visible to false after the loop, otherwise it will become invisible before it fades.
    imageLabel.Visible = false
Ad

Answer this question