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

GUI fades in, but fading out doesn't work? [EDIT]

Asked by 10 years ago

So I made this script, I added the fade out, but it comes with the error

Workspace.Stick.In:25: attempt to index global 'hit' (a nil value)

I know that that means It doesn't know what 'hit' is, but it's at the top of the script.

script.Parent.Touched:connect(function(hit)


    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        local character = hit.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        local notice = player.PlayerGui.Notice.Notice

    for i=1,0, -0.1 do
        wait(0.1)
        notice.Text = "You Found a Branch"
        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i

end

    end


end)
wait(3)


        local character = hit.Parent
        local player = game.Players:GetPlayerFromCharacter(character)
        local notice = player.PlayerGui.Notice.Notice

    for i=1,0, -0.1 do
        wait(0.1)
        notice.BackgroundTransparency = i
        notice.TextTransparency = i
        notice.ImageLabel.ImageTransparency = i
        notice.Text = ""


    end

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago

It's simple; "fade in" and "fade out" are just opposites of eachother.

You already have it going from dark to light, now you just need to reverse it, i.e.

for i = 0, 1, 0.1 do
    print(i)
end
Ad

Answer this question