Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Why isn't my gui being cloned to PlayerGui?

Asked by 10 years ago
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

Log in to vote
-1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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)
Ad

Answer this question