How to fix the guis not being cloned after the loading is done!

  1. What do you want to achieve? Trying to make the guis show when the custom loading is done.

  2. What is the issue? Doesn’t clone the guis from replicated storage then clone it to playergui when the loading is done!

  3. What solutions have you tried so far? Try using different code but still doesn’t clone the guis.

-- Local Script on ReplicatedFirst (There is more code but I don't want to leak it)
local Guis = game.ReplicatedStorage:GetChildren()

-- Doesn't clone the gui then Enabled it
for i, v in pairs(Guis) do
	if v:IsA("ScreenGui") then
		local gui = v:Clone()
		gui.Enabled = true
		gui.Parent = PlayerGui
	end
    wait(0.2)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Is this a server script or local script?

1 Like

local script on ReplicatedFirst

Why do you need to clone it in PlayerGUI instead of putting all the GUIs in the StarterGUI? If you are concerned of resetting, just disable ResetOnSpawn.

Since you’re calling ReplicatedStorage:GetChildren() from ReplicatedFirst, there’s the possibility nothing exists at the time of indexing, you’ll need WFC here somehow,

local Guis = game:GetService("ReplicatedStorage"):GetChildren()

Remember whatever you put in game.ReplicatedFirst is among the first to replicate to the client, and so anything other than that might’ve not replicated at that time.

If you’re getting any other errors then tell us, they won’t be leaked.


You don’t need to include that by the way.

1 Like

I not talking about the loading sceen I talking about all the other guis like team guis to be cloned after the custom loading sceen.

I clone the custom loading screen from ReplicatedFirst then after the custom loading is done the guis show smoothly instead of guis being loaded by default.

I don’t really understand what you’re trying to say, but did you try using WaitForChild() ?

Edit:

You aren’t understanding my point,

I’m saying they didn’t show up because whatever you put in ReplicatedFirst replicates before other stuff, that other stuff is services’ contents like ReplicatedStorage’s contents and therefore you need to yield till they exist for a player or have replicated, you can achieve that through Instance:WaitForChild.

Edit2: yeah I forgot to include where the WFC would fit in, sorry.

If you haven’t got too many Gui, then do something like

 local rs = game:GetService("ReplicatedStorage")
 local ToLoad = {"GuiName1", "GuiName2"} -- add all Gui names here

 for _, v in ipairs(ToLoad) do
     rs:WaitForChild(v)
 end

 -- now continue with your previous loop

If it didn’t work then just parent all your Gui components to ReplicatedFirst, and keep the script at the lowest level of hierarchy in any of them, you might need to adjust your code a bit.

Can you also share how you incorporated the first method in your script?

Edit 3: Yes, you do have to set the parent to PlayerGui, I’m saying initially keep your Gui in ReplicatedFirst instead of ReplicatedStorage.

Edit 4 : NOO , that’s now what I meant - show me the current code you’ve got.

1 Like

Is there a way to load the guis one by one instead of the guis loaded before the loading is done? I already have guis in ReplicatedStorage but they didn’t show up after custom loading was done.


for i, v in pairs(Guis) do
if v:IsA(“ScreenGui”) then
local gui = v:Clone()
gui.Enabled = true
gui.Parent = PlayerGui
end
wait(0.2)
end

Yea but then the for loop will not clone it one by one by one. You mean game:WaitForChild(“ReplicatedStorage”) ?

Edit: :WaitForChild didn’t fix the for loop and still doesn’t clone the guis.

Ok hopefully it works. I try it to see if it fix the problem.

But don’t I have to set the v parent to playergui?
Edit: Ok I see if it works with ReplicatedStorage then ReplicatedFirst if it doesn’t work.

I see now. I think this will 100% work.

Edit: I did that now.
Edit 2: Yea I think ReplicatedFirst would be better for the guis.

To work with all Gui in ReplicatedStorage, as in the beginning.

local names = {"GuiName", "AnotherGuiName"} -- put names of all Gui you will index as strings here
local ReplicatedStorage = game.ReplicatedStorage


for _, name in ipairs(names) do
    ReplicatedStorage:WaitForChild(name)
end

local Guis = ReplicatedStorage:GetChildren()
for _, v in ipairs(Guis) do
	if v:IsA("ScreenGui") then
		local gui = v:Clone()
		gui.Enabled = true
		gui.Parent = PlayerGui
	end
    wait(0.2)
end

Remember to insert the name of every Gui that’ll need to be cloned in the names table, so it’ll yield till they’ve loaded.

The better method would be to just put all Gui you need early under ReplicatedFirst.

1 Like

Thanks for your help it works well.

1 Like