ScreenGui wont duplicate into player on respawn

Hello, I just made a loading screen a few days ago and I realized something: the ScreenGui wont clone into a player on respawn even though it is placed into StarterGui. Here is part of the loading screen script:

local function GiveGui()
	local MainGui = script:WaitForChild("Main"):Clone()
	MainGui.Parent = game.StarterGui
	MainGui:Clone().Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
	game.Players.LocalPlayer:WaitForChild("PlayerGui"):SetTopbarTransparency(1)
end

It has ResetOnSpawn set to true.
Any help is appreciated!

I believe you would be wanting to do

MainGui.Parent = game.Players.LocalPlayer.PlayerGui

instead.

I’m not entirely sure by what your actual goal is from the post, so I may be off. If it’s not what you meant, please let me know and I’ll provide some questions such that we can help you further.

What is the SetTopbarTransparency even?? It doesn’t exist?

Can’t you clone MainGui directly into PlayerGui?

This will not work because you are cloning the Gui into StarterGui using a script after the Player has joined the game.

The Gui will only be cloned into the Player when you directly drag it into StarterGui before the game even starts. E.G (Without a script & Dragging the Gui into the game.StarterGui folder)

ResetOnSpawn only works if the Gui was placed inside of the Player by dragging it into StarterGui, and not by cloning it in there with a script.

After that if they respawn the GUI will respawn as well. By the off chance you are not calling the GiveGui function by running it make sure you do that as well.

local function GiveGui()
--Insert Code here
end
GiveGui() --Make sure to run it 

Please select as the answer if this solved your problem :slight_smile:

Just make the whole GUI visible whenever you update/public the game and then disable it again so you can continue working on it. This will make it so everytime the player dies the whole function with the GUi starts over.

I’m already doing this on the 4th line.

So, should I clone it with a script or is there anyway to do it automatically?

ScreenGui should automatically replicate into playergui. But if it doesn’t, try removing line 3 and replacing line 4 with MainGui.Parent = game.Players.LocalPlayer.PlayerGui

If you want it to be in your GUI when you respawn you have to drag it into the StarterGui like the GIF I provided:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.