Loading intro not working?

So I have this intro im editing right now, and im trying to display the “frameBackground” while waiting, and once the game is loaded, the rest goes on, but its not working that way, what am I doing wrong?

wait(0.1)

--// Client

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Camera = game.Workspace.CurrentCamera

game.Lighting.Blur.Size = 15

--// GUIs

local PlayButton = script.Parent.PLAY

--// Main

Camera.CameraType = Enum.CameraType.Scriptable

repeat wait() until script.Parent.Parent == game.Players.LocalPlayer:WaitForChild("PlayerGui")

repeat wait()

Camera.CameraType = Enum.CameraType.Scriptable

until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame

while not game:IsLoaded() do

script.Soundsx:Play()

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

script.Parent.frameBackground.Visible = true

local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()

local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren()

local imageBackPat = script.Parent.frameBackground.imageBackgroundPattern

local imageBackPat2 = script.Parent.frameBackground.imageBackgroundPattern2

Camera.CameraType = Enum.CameraType.Scriptable

Camera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame

local inf = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0);

local goal = {ImageTransparency = 1;}

local ts = game:GetService("TweenService");

local function transp(children)

for x,y in pairs(children) do

if y:IsA("ImageLabel") or y:IsA("ImageButton") then

local tween = ts:Create(y, inf, goal);

tween:Play();

end

end;

end;

end;
4 Likes

Why there is semicolons at the end?

Where this script is? In StarterGui?

1 Like

No its a gui given when the player joins, and the script is inside the gui, (local)

The code appears to be badly formatted, and its very hard to read
Maybe use some coding style so we can read the code

It could possibly the repeat wait() you have there below where you set the camera type, have you tried removing that? You didn’t add an until statement so it will just be infinitely waiting for nothing.

It doesn’t really matter if there are semicolons, Roblox just ignores them anyways unless they are in a table of some sort.

i didn’t know because I never saw semicolons in roblox scripts at the end of line

Trust me, they do work. I’ve used them many times before and Studio just pretends they don’t exist unless they’re in a table.

I was able to make this, but it does not work still, any help?

wait(0.1)

--// Client

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Camera = game.Workspace.CurrentCamera

game.Lighting.Blur.Size = 15

game.ReplicatedFirst:RemoveDefaultLoadingScreen()

boi = false

--// GUIs

local PlayButton = script.Parent.PLAY

--// Main

Camera.CameraType = Enum.CameraType.Scriptable

repeat wait() until script.Parent.Parent == game.Players.LocalPlayer:WaitForChild("PlayerGui")

repeat wait()

Camera.CameraType = Enum.CameraType.Scriptable

until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame

script.Soundsx:Play()

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

script.Parent.frameBackground.Visible = true

if game:IsLoaded() then

if boi == false then

boi = true

local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()

local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren()

local imageBackPat = script.Parent.frameBackground.imageBackgroundPattern

local imageBackPat2 = script.Parent.frameBackground.imageBackgroundPattern2

Camera.CameraType = Enum.CameraType.Scriptable

Camera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame

local inf = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0);

local goal = {ImageTransparency = 1;}

local ts = game:GetService("TweenService");

local function transp(children)

for x,y in pairs(children) do

if y:IsA("ImageLabel") or y:IsA("ImageButton") then

local tween = ts:Create(y, inf, goal);

tween:Play();

end

end

end;

end;

end;
1 Like

You should remove the repeat wait() parts as ideally you should avoid using these due to slow performance and secondly they are not necessary at all.

repeat wait() until script.Parent.Parent == game.Players.LocalPlayer:WaitForChild("PlayerGui")

I assume by this you are waiting until the parent of the GUI is a member of PlayerGui, where are you setting the parent of this GUI? Is this in another script that is fired when the player joins the server? This shouldn’t even be necessary to wait for this as the script will only run once it’s parented anyway.

The repeat wait used to set the cameratype to scriptable is also not needed. It’s an unnecessary repeat wait. You can just do Camera.CameraType = Enum.CameraType.Scriptable and be done with it.

Below is some more information on why you should avoid using wait()

1 Like

Well the only reason I am doing all this is because I want my intro to be loaded, I have had so many times where players complain of the intro not loading. So I do not know how to make it so the intro loads first, or loads in the first place.

1 Like

That’s not how it works, just remove the single repeat wait().
image
Plus like @serverIess said,

1 Like

The repeat on the camera is from an issue of the camera not changing, and keeping the players camera.

And again, how would I be able to make the intro load first so this isn’t an issue?

1 Like

The repeat wait() I selected in the photo is most likely your issue. You have to remove that because it will yield infinitely, and the loading screen will never show up. You still had it in the updated script you posted, so I’m not sure if you have tried to remove it, or just didn’t end up removing it.

1 Like

There are some fundamental code errors to be addressed here.

  • Yielding at the beginning of a thread is pointless (in this case, waiting 0.1 seconds at the start of the script’s running) and a code smell related to loading. Why are you waiting 0.1 seconds?

    • The LocalPlayer is implicitly available to LocalScripts.

    • Get rid of waiting for the character to be added. You don’t use the character and the loading screen has no need for the character when initialising. You can access it later but definitely not at the start of its lifetime.

  • If your code isn’t in ReplicatedFirst, calling RemoveDefaultLoadingScreen is pointless. The loading screen disappears when game.Loaded fires or after 5 seconds if a LocalScript in ReplicatedFirst calls the function.

    • In addition to this, later in your code, you check for game:IsLoaded() to be true. If your code is not in ReplicatedFirst, LocalScripts will not run until game.Loaded fires. Checking for game:IsLoaded() outside of ReplicatedFirst has no purpose.
  • The repeat loops for any of the camera items are unnecessary. Get rid of all repeat loops.

  • Try doing something about your readability sometime? What you’ve presented here is frankly spaghetti code. I’m sure it’d help with trying to update the script.

Then your thread.

  • This thread lacks information. Instead of saying “X doesn’t work”, please explain your problem thoroughly. Include details and images so others can help you (e.g. console).

  • Please try debugging your code if there are simple errors to be found.

Semicolons are actually used to signify the end of a line, which means theoretically you could minify lua code, but there is little to no performance benefits.

Regarding the OP, the reason why your repeat wait() statement is an error, is because you do not have anything telling the script to continue. If you insist on having this here, you will need repeat wait() until and then add a parameter, as others have said, this statement causes the script to wait indefinitely.

I am not concerned about this however, I am concerned that you are approaching the problem at hand in a very inefficient way.

Here are a few things that I noticed you are doing:

  • There is a wait(0.1) at the top of your script, I have no idea why this is before the variables, as this is not needed at all.
  • Assuming you are using a ServerScript to clone the Intro GUI into the player, you have a very weird way of detecting that the player is there. repeat wait() until script.Parent.Parent == game.Players.LocalPlayer:WaitForChild("PlayerGui") , this is also not needed, as the local script does not need to wait for it to be parented to the player, since it will automatically be parented to the player, and the script that is inside of the decendant of the ServerScript will ultimately be a clone, and therefore will not ever be updated.
  • As said by someone else, removing the default loading screen will have no effect, unless you are using this in ReplicatedFirst.

I propose you structure your code like this:

--// ServerScript in ServerScriptStorage

game.Players.PlayerAdded:Connect(function(Player)
	local UI = script[UIName]:Clone()
	UI.Parent = Player.PlayerGui	
end)

--// LocalScript inside of UI

--// Variables 

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = game.Workspace.CurrentCamera
local ts = game:GetService("TweenService");
game.Lighting.Blur.Size = 15
boi = false

--// Main

Player.CharacterAdded:Connect(function()
	if boi == false then			
		boi = true
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = game.Workspace:WaitForChild("CameraPart").CFrame
		script.Soundsx:Play()
		game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
		script.Parent.frameBackground.Visible = true
		local dog = script.Parent.frameBackground.frameBackgroundBottom:GetChildren()	
		local dog2 = script.Parent.frameBackground.frameBackgroundTop:GetChildren()	
		local imageBackPat = script.Parent.frameBackground.imageBackgroundPattern	
		local imageBackPat2 = script.Parent.frameBackground.imageBackgroundPattern2
		local PlayButton = script.Parent.PLAY
		local inf = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0);
		local goal = {ImageTransparency = 1;}
		local function transp(children)
			for x,y in pairs(children) do
				if y:IsA("ImageLabel") or y:IsA("ImageButton") then
					local tween = ts:Create(y, inf, goal);
					tween:Play();
				end
			end
		end
	end
end)
1 Like

You can minify Lua without semicolons. Semicolons are a requirement in some languages to specify the end of a chunk but that isn’t forced with Lua and can be ignored.

2 Likes