GUI Clone upon Player Joins Not Updating

Hello, I am making a GUI whereas whenever a player joins, the GUI Clones into the corresponding place. This all works for the first player who joins, but it won’t update anymore. Here is a code snippet for a better understanding of my issue:

game.Players.PlayerAdded:Connect(function(plr)
	local Console = game.StarterGui:WaitForChild("Console")
	
	local clonedUI = game.StarterGui:FindFirstChild("playerName"):Clone()
	clonedUI.Parent = Console:FindFirstChild("Frame"):FindFirstChild("ScrollingFrame")
	clonedUI.Text = plr.Name
	clonedUI.Name = plr.Name
	
	local clonedCash = game.StarterGui.GiveMoney:Clone()
	clonedCash.Parent = Console.Frame.MoneyFrame
	clonedCash.Text = plr.Name
	clonedCash.Name = plr.Name
end)

My guess is that the issue comes from you indexing stuff in StarterGui and cloning from it. I actually don’t even know how it would behave as StarterGui clones all of its contents to the player’s PlayerGui instance when they join.

First of all, use a folder that isn’t inside any of the special services. Even the Script this code is in will do.

local Console = script:WaitForChild("Console"):Clone()

local clonedUI = script:FindFirstChild("playerName"):Clone()
clonedUI.Parent = Console:FindFirstChild("Frame"):FindFirstChild("ScrollingFrame")
clonedUI.Text = plr.Name
clonedUI.Name = plr.Name

local clonedCash = script.GiveMoney:Clone()
clonedCash.Parent = Console.Frame.MoneyFrame
clonedCash.Text = plr.Name
clonedCash.Name = plr.Name

Console.Parent = plr:WaitForChild("PlayerGui")

Is this a local or server script?

This is inside a serverscript.

Change this to:

local Console = plr.PlayerGui:WaitForChild('Console')

Actually,
Just change your script to this:

game.Players.PlayerAdded:Connect(function(plr)
	local Console = plr.PlayerGui:WaitForChild("Console")
	
	local clonedUI = plr.PlayerGui:FindFirstChild("playerName"):Clone()
	clonedUI.Parent = Console:FindFirstChild("Frame"):FindFirstChild("ScrollingFrame")
	clonedUI.Text = plr.Name
	clonedUI.Name = plr.Name
	
	local clonedCash = plr.PlayerGui.GiveMoney:Clone()
	clonedCash.Parent = Console.Frame.MoneyFrame
	clonedCash.Text = plr.Name
	clonedCash.Name = plr.Name
end)

All items from StarterGui get cloned into the Player’s PlayerGui when they join.

1 Like

I tried this method but it didn’t work; I also tried @nooneisback’s one but it didn’t work.

Can you send an image of your layout?

image

Gui objects must be inside a ScreenGui for them to appear.

Yeah, I cloned them via script to appear in the corresponding Gui. It looks like this when cloned:

image

Do you receive any errors at all?

Nope, it clones once but that’s really it.

Try using an event perhaps? That might work.

Okay, I have something interesting to show:
I tried to print something when the PlayerAdded event is called, when players join it prints each time so there’s definitely something wrong with the cloning.

Try this?

game.Players.PlayerAdded:Connect(function(plr)
        plr.CharacterAdded:Connect(function(character)
	local Console = plr.PlayerGui:WaitForChild("Console")
	
	local clonedUI = plr.PlayerGui:FindFirstChild("playerName"):Clone()
	clonedUI.Parent = Console:FindFirstChild("Frame"):FindFirstChild("ScrollingFrame")
	clonedUI.Text = plr.Name
	clonedUI.Name = plr.Name
	
	local clonedCash = plr.PlayerGui.GiveMoney:Clone()
	clonedCash.Parent = Console.Frame.MoneyFrame
	clonedCash.Text = plr.Name
	clonedCash.Name = plr.Name
       end)
end)

Sorry for the bad intending.

If this works, it’s a start.

1 Like

No, it doesn’t work after adding CharacterAdded Event

I believe that your problem is that it should be done from the client.

Put the buttons in replicated storage, and then from your console ui, make a local script inside that, use a playerAdded event in the server and then detect it on the client and add the player to the list by cloning the ui from replicatedStorage.

This still doesn’t work, I tried everything

I believe this issue is on your end then.