Script not giving the player GUIs properly

So I’m trying to make it so that whenever a player joins, the GUI stored inside of a folder in the script below (this script is inside of ServerScriptService and is a BaseScript) gets replicated and added to the client’s PlayerGui. So far everything is working… except for the plr.CharacterAdded:Connect(function(char) part of the script, it just won’t add the GUI to the client. No errors, it prints that the GUI does exist in PlayerGui, but when I look in the explorer tab while testing and go to Players.ScriptedSuper.PlayerGui, it’s not there… someone please help, thanks.

game.Players.PlayerAdded:Connect(function(plr)
    local charCount = 0;
    local c = script.ClientGUIs:WaitForChild("Core UI"):Clone()
    c.Parent = plr.PlayerGui;
    if plr:GetRankInGroup(8755895) >= 13 then
        local clone = script["Admin Button"]:Clone()
        clone.Parent = c.Container;
        local clone2 = script["Panel"]:Clone()
        clone2.Parent = c.Container;
    end
    plr.CharacterAdded:Connect(function(char)
        print("a")
            local d = script.ClientGUIs:WaitForChild("Core UI"):Clone()
            d.Container.Visible = true;
            d["Loading Screen"].Visible = false;
            d["Main Menu"].Visible = false;
        d.Parent = plr.PlayerGui;
        print(d.Parent.Name)
        print(d.Enabled)
            if plr:GetRankInGroup(8755895) >= 13 then
                local clone = script["Admin Button"]:Clone()
                clone.Parent = d.Container;
                local clone2 = script["Panel"]:Clone()
                clone2.Parent = d.Container;
            end
    end)
end)

Probably because the character is already added when the event is ready to be executed.
Here’s a quick fix (with functions):

local Players = game:GetService('Players')


local function PlayerAdded(Player)
   -- Code for PlayerAdded.
   local function CharacterAdded(Character)
      -- Code for CharacterAdded.
   end
   -- Check if character has been added.
   local Character = Player.Character
   if (Character) then
   CharacterAdded(Character)
   end
   Player.CharacterAdded:Connect(CharacterAdded) -- Listen for CharacterAdded event.
end


local GetPlayers = Players:GetPlayers()
for i = 1, #GetPlayers do
   task.spawn(PlayerAdded, GetPlayers[i])
end
Players.PlayerAdded:Connect(PlayerAdded)

Didn’t work, but thanks for trying.

Add a print inside the CharacterAdded function (first line).

Don’t need help anymore, going to do this another way.