Can't get GUI to fade in

I’m trying to make my GUI fade out and then another GUI fade in. I can get the GUI to fade out, however I cannot get the GUI I need to fade in.

local frame = script.Parent

local LOGO = script.Parent.LOGO

local Stu = script.Parent.Studios

local TITLE = game:WaitForChild("StarterGui").TitleScreen

local TEXTS = TITLE.Menu.TextButton

local MAFIA = TITLE.Menu.Mafia

local sound = game:GetService("StarterGui").TitleScreen.Menu["Audio/MafiaTown"]

local MENU = game:WaitForChild("StarterGui").TitleScreen.Menu

game:WaitForChild(MENU)

wait(5)

for i = 0,100 do
	LOGO.ImageTransparency += 0.01
	Stu.TextTransparency += 0.01
	frame.Transparency += 0.01
	MENU.BackgroundTransparency += 0.00
	wait(0.01)
end

wait(2)

for i = 0,1 do
	TEXTS.TextTransparency += 0
	MAFIA.TextTransparency += 0
	sound:Play()
	sound.Looped = true
end

TEXTS.MouseButton1Click:Connect(function()
	for i = 1,100 do
		TEXTS.TextTransparency += 0.01
		MAFIA.TextTransparency += 0.01
		MENU.Transparency += 0.01
	end
	sound:Destroy()
	TITLE:Destroy()
	script.Parent:Destroy()
end)

This is the script I have. What I got so far is the one GUI to fade out and then when the “text button” is clicked it locks to a part. (The camera locks to the part.) I’m still very new to scripting so I’m probably missing something extremely simple.

Which GUI element do you want it to fade in?

If its all of them, you should set their Transparencies to 1 then do “-=” then add a wait function.
Also, this for loop isn’t very smooth. You should consider using a TweenService. Since you’re new to scripting, I can help you with it.

You are setting the ui properties in the starter gui, change their properties in the playergui of the local player.

2 Likes

Like @FloofyPlasma said use PlayerGui instead of StarterGui to change a gui propriety on client.
Here is an example script i use for my fadein frame

local frame = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("LamLantern"):WaitForChild("Frame")

The Gui itself is located in a localscript and is parented to playergui.
Here is how i parent it

local guicount = script:FindFirstChild("LamLantern")
guicount.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")

This helped a lot! It’s now functioning the way I need it to thank you! Only problem now is that the camera randomly stopped working lol

local frame = script.Parent

local RunService = game:GetService("RunService")

local LOGO = script.Parent.LOGO

local Stu = script.Parent.Studios

local players = game:GetService("Players").LocalPlayer

players.PlayerGui:WaitForChild("TitleScreen")

local TITLE = players.PlayerGui.TitleScreen

local cc = workspace.CurrentCamera

local PART = workspace.CAM2

local TEXTS = TITLE.Menu.TextButton

local MAFIA = TITLE.Menu.Mafia

local sound = game:GetService("StarterGui").TitleScreen.Menu["Audio/MafiaTown"]

local MENU = TITLE.Menu

local isOn = false

game:WaitForChild(MENU)

wait(5)

for i = 0,100 do
	LOGO.ImageTransparency += 0.01
	Stu.TextTransparency += 0.01
	MENU.BackgroundTransparency -= 0.00
	wait(0.01)
end

wait(2)

for i = 0,1 do
	TEXTS.TextTransparency -= 1
	MAFIA.TextTransparency -= 1
	MENU.BackgroundTransparency -= 1
	sound:Play()
	sound.Looped = true
end

TEXTS.MouseButton1Click:Connect(function()
	for i = 1,100 do
		TEXTS.TextTransparency += 0
		MAFIA.TextTransparency += 0
		MENU.BackgroundTransparency += 0
	end
	wait()
	if not isOn then
		cc.CameraType = Enum.CameraType.Scriptable
		isOn = true
	else
		cc.CameraType = Enum.CameraType.Custom
		isOn = false
	end
	sound:Destroy()
	TITLE:Destroy()
	script.Parent:Destroy()
end)

RunService.RenderStepped:Connect(function()
	if isOn then
		cc.CFrame = PART.CFrame
	end
end)

I’m not sure if they are allowed to look around the part, but this this should fix your problem.
I have put the camera code into the button, but if needed you can move it back into the renderStepped loop.

TEXTS.MouseButton1Click:Connect(function()
	for i = 1,100 do
		TEXTS.TextTransparency += 0
		MAFIA.TextTransparency += 0
		MENU.BackgroundTransparency += 0
	end
	wait()
	if not isOn then
		cc.CameraSubject = PART
		wait()
		cc.CameraType = Enum.CameraType.Scriptable  -- Remove if player is allowed to zoom/look around the view part.
		isOn = true
	else
		cc.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		wait()
		cc.CameraType = Enum.CameraType.Custom -- Remove if player is allowed to zoom/look around the view part.
		isOn = false
	end
	sound:Destroy()
	TITLE:Destroy()
	script.Parent:Destroy()
end)

The reason it didn’t fade in, is because you didn’t -= the transparency a single time in your code. Also, what’s the point of x.texttransparency += 0?

I realized this after the fact, as I said I’m new to scripting and it was something I overlooked.

Thank you! This helped a lot! :smiley: