Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.