Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't my gui being cloned to PlayerGui?

function player_addition(Plyr)
repeat wait() until Plyr.Character and Plyr.Character.Humanoid.Health >= 5
local A = Instance.new("BoolValue")
A.Name = "Loading_01"
A.Parent = Plyr.PlayerGui.L_Data
A.Value = true
Plyr.CharacterAdded:connect(function(Character)
repeat wait() until Plyr.Character and Plyr.Character.Humanoid.Health >= 5
Plyr.PlayerGui:WaitForChild("L_Data")
if Plyr.PlayerGui.L_Data.Loading_01.Value == true and Plyr.PlayerGui:FindFirstChild("Loading_Gui") == nil then
game.ReplicatedStorage.Loading_Gui:clone().Parent = Plyr.PlayerGui <---Problem starts here. 
end

Plyr.CharacterAdded:connect(function(Character_01)
Character_01:WaitForChild("Humanoid").Died:connect(function()
repeat wait() until Plyr.Character and Plyr.Character.Humanoid.Health >= 5
Plyr.PlayerGui:WaitForChild("L_Data")
if Plyr.PlayerGui.L_Data.Loading_01.Value == true and Plyr.PlayerGui:FindFirstChild("Loading_Gui") == nil then
game.ReplicatedStorage.Loading_Gui:clone().Parent = Plyr.PlayerGui
end
end)
end)
end)
end
game.Players.PlayerAdded:connect(player_addition)

1 answer

I did my own tweaking a bit. You didn't need a second CharacterAdded event.

game.Players.PlayerAdded:connect(function(Plyr)
	repeat wait() until Plyr.Character and Plyr.Character.Humanoid.Health >= 5
	local A = Instance.new("BoolValue")
	A.Name = "Loading_01"
	A.Parent = Plyr.PlayerGui.L_Data
	A.Value = true
	Plyr.CharacterAdded:connect(function(Character)
		repeat wait() until Plyr.Character and Plyr.Character.Humanoid.Health >= 5
		Plyr.PlayerGui:WaitForChild("L_Data")
		if Plyr.PlayerGui.L_Data.Loading_01.Value == true and not Plyr.PlayerGui:FindFirstChild("Loading_Gui") then
			game.ReplicatedStorage.Loading_Gui:clone().Parent = Plyr.PlayerGui <---Problem starts here.
		end
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.