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

How can I make a gui turn transparent so another one can turn visible?

If my question title seems confusing, then I mean like when you see in game its like

"Welcome to my game....." the gui turns black then another GUI slowly fades in saying

"Made by [person]" Yea. I'm trying to make that

Code that is the problem:

for i = 0, 1, 0.1 do
			local b = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.Loading
			local a = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.LoadingNew
			b.Transparency = i
			wait(3)
			for i = 1, 0.1, 1 do
				a.Tansparency = i 
			end
		end

Whole code:

function Touch(Item)
	if Item.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(Item.Parent) then
		local PlayerGui = game.Players:GetPlayerFromCharacter(Item.Parent).PlayerGui
		PlayerGui.Checkpoints.EndofLevel.End.Background1.Visible = true
		wait(5)
		for i = 0, 1, 0.1 do
			local b = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.Loading
			local a = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.LoadingNew
			b.Transparency = i
			wait(3)
			for i = 1, 0.1, 1 do
				a.Tansparency = i 
			end
		end
		PlayerGui.Checkpoints.EndofLevel.End.Background1:remove()
		print('work')
		if workspace.Level1.SL2.Enabled == true then
			workspace.Level1.SL2.Enabled = false
			workspace.Level2.SL3.Enabled = true
		end
	end
end

script.Parent.Touched:connect(Touch)

function onTouch(hit)
	local b = hit.Parent:FindFirstChild("Humanoid")
	if b ~= nil then
		b.Health = 0
	else
		print("noooo")
	end
end

script.Parent.Touched:connect(onTouch)

3 comments

0

After the for loop on line six of your first code block, make sure to turn IsVisible to false and change the next on to true with a transparency of 0 and do another for loop. I'm sure I was no help at all. (: At least know I tried (= Sorry, and good luck!

0

Ok, I could probably help you with what you are making so when a player joins it says "Welcome to my game" "Made by:..." And both of those fade away right?

0

Nono, I'm not trying to make that. If I can, I'll post a picture of what I'm trying to do.

1 answer

✓ Accepted answer

What your code is trying to do, is loop 10 times, increasing the "i" variable from 0 to 1 and setting the transparency of b to i. That is perfectly fine. The problem is, every time this loops, there is another loop which is trying to loop from 1 to 0.1 with in increment of 1 which, obviously, won't work.

(Also the property is BackgroundTransparency, not Transparency)

Try the following code:

local b = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.Loading
local a = PlayerGui.Checkpoints.EndofLevel.End.Background1.Holder1.LoadingNew

--This first loop will fade b in--

for i = 1, 0, 0.1 do --Will loop ten times
	b.BackgroundTransparency = i --Setting the transparency of b to i
	wait(0.1) --So it doesn't instantly change transparency to 0
end

wait(3) --Time period before the next one fades in

for i=1, 0, 0.1 do --Will loop 10 times
	a.BackgroundTransparency = i --Will make a visible
	b.BackgroundTransparency = 1-i --Will make b invisible
	wait(0.1) --To slow it down a bit
end

Obviously I can't see your GUI, but if you don't want to make b invisible at the end, just remove line 15.

I hope this helps!

4 comments

0

It doesn't work.

0

Any errors?

0

I had to rewrite your code. Kinda works, but its a little weird

0

How so? You can make the wait smaller to speed it up, and increase the increment by making 0.1 smaller

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