1. Is there anything wrong with these commands? He should check (at the time I get into the game) who is more than 30 days off and remove from the guild

     local kick = 0
     local function onUpdate(self)
        if kick == 0 then
            if not CanGuildRemove() then
                return
            end
            for i=1,GetNumGuildMembers() do
                local y,m,d=GetGuildRosterLastOnline(i)
                if y then
                    if y>0 or m>0 or d>30 then
                        GuildUninvite(GetGuildRosterInfo(i))
                    end
                end
            end
            kick = 1
        end
     end
    
     local f = CreateFrame("frame")
     f:SetScript("OnUpdate", onUpdate)
    

    The first thing is this runs every single time the screen refreshes. This is absolutely insane. Run it ONCE. Don't use an OnUpdate. But no, other than that I don't see anything logically wrong with it.

    There are some players with more than 30 days without getting in my guild, I run this addon and it is not working properly, have no idea of what can be?

    No. Debug it. Find out what's happening.

    I performed a check of the code and it really is working, but he kicked out the players with more than 30 days and is trying to remove self-guild also, what might be happening?

    I don't know. You need to debug it. Add some print statements. Find out what is happening. This isn't something I can test for you.

    What exactly is happening is the following.

    I activate the addon and so my game finishes loading the screen, it automatically kicks who has more than 30 days away.

    What is happening is that it is trying to kick my self constantly until my game closes by flood.

    What can be?

    You are missing the point entirely. Let me attempt to be clearer.

    1. I don't have this addon.
    2. I don't have a guild in which I can test this.
    3. I've already given you one problem with the code you've posted.
    4. Therefore YOU have to debug this. You have to figure out what is going wrong.

    Do this:

     function KickOldFromGuild(actuallyKick)
        if not CanGuildRemove() and actuallyKick then
            return
        end
        for i=1,GetNumGuildMembers() do
            local y,m,d=GetGuildRosterLastOnline(i)
            if y then
                if y>0 or m>0 or d>30 then
                    if actuallyKick then
                        GuildUninvite(GetGuildRosterInfo(i))
                    else
                        print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d))
                    end
                end
            end
        end
     end
    
     local frame = CreateFrame("Frame")
     frame:RegisterEvent("PLAYER_LOGIN")
     frame:SetScript("OnEvent", function(self, event, ...)
        -- This line will run it in debug mode, so no one is kicked
        KickOldFromGuild(false)
        -- This line would run it and actually try to kick
        -- KickOldFromGuild(true)
     end)
    

    Now it runs ONCE, not every single screen refresh. It also waits for the appropriate initialisation event to run. It also has a boolean flag that lets you run it in debug mode, where it prints instead of kicks. It also has a global name so you can call it whenever you want rather than having to reload your UI.

    These are codes that you spent working very well and I really appreciate your attention, but he's an obstacle that all my other codes were.

    As soon as I enter the game nothing happens, it only executes the command when I give /reload

    Then call KickOldFromGuild(true) or KickOldFromGuild(false). /run KickOldFromGuild(false).

    I edited the command line to call ... local frame = CreateFrame("Frame") frame:RegisterEvent("PLAYER_LOGIN") frame:SetScript("OnEvent", function(self, event, ...)

    -- This line will run it in debug mode, so no one is kicked
    -- KickOldFromGuild(false)
    -- This line would run it and actually try to kick
    KickOldFromGuild(true)
    

    end)

    but still it does not run when entering the game

    Does it not run? How do you know it doesn't run? Do you have an error? Did you add a print statement to ensure that its not getting run?

    I cannot debug this for you. You want it done another way, then fine:

     local frame = CreateFrame("Frame")
     frame:SetScript("OnUpdate", function(self, elapsed)
       KickOldFromGuild(true)
       self:Hide()
     end)
    

    It'll run once the game starts and run only once. I can't tell you why the other isn't working because you refuse to help me debug or provide any information.

    I know that is not working because when I went into the game, he did not send nor print or remove players with 30+ guild.

    And so I gave the /reload he did the removal.

    I changed the code as you showed, but still does not run unless I command to /reload

    Sorry even if I have not given enough information, but I'm an extreme beginner in this subject and I do not know how to do a more detailed calculation

    Open Interface Options -> Go to Help -> Display Lua Errors (select this). Does the code give you an error when you login?

    Ok, I activated the option that you mentioned.

    I login but nothing happened, only after I /reload

    Post every single file of your addon here. Everything, the .toc file, the .lua file. Everything.

    Sorry for the delay friend, but had to give attention to my family. The code of each file are ...

     OldPlayer.toc
     ## Interface: 40000
     ## Title: |cFF086BCDEOldPlayer|r
     ## Version: 0.1
     ## Notes: Kick old players
     ## Author: Deltoide
     OldPlayer.lua
    
     ***************************************
    
     OldPlayer.lua
     function KickOldFromGuild(actuallyKick)
         if not CanGuildRemove() and actuallyKick then
             return
         end
         for i=1,GetNumGuildMembers() do
             local y,m,d=GetGuildRosterLastOnline(i)
             if y then
                 if y>0 or m>0 or d>29 then
                     if actuallyKick then
                         --GuildUninvite(GetGuildRosterInfo(i))
                     else
                         print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d))
                     end
                 end
             end
         end
      end
    
      local frame = CreateFrame("Frame")
      frame:SetScript("OnUpdate", function(self, elapsed)
        KickOldFromGuild(true)
        self:Hide()
      end)
    
     function KickOldFromGuild(actuallyKick)
        if not CanGuildRemove() and actuallyKick then
            return
        end
        for i=1,GetNumGuildMembers() do
            local y,m,d=GetGuildRosterLastOnline(i)
            if y then
                if y>0 or m>0 or d>29 then
                    if actuallyKick then
                        GuildUninvite(GetGuildRosterInfo(i))
                    else
                        print(string.format("Would kick %s, y: %d, m: %d, d: %d", GetGuildRosterInfo(i), y, m, d))
                    end
                end
            end
        end
     end
    
     -- Wait until the guild information is available the first time after login
     local frame = CreateFrame("Frame")
     frame:RegisterEvent("GUILD_ROSTER_UPDATE")
     frame:SetScript("OnEvent", function(self, event, ...)
        print("Guild information is available, running OldPlayer checker")
        KickOldFromGuild(false)
     end)
    

    That should do it, it will run anytime the guild roster is updated. The function was absolutely running before, if you had debugged it at all you would have seen that. The problem was the guild roster is not immediately available when logging in, so it saw you had 0 guild members, and didn't have to do any other work. The information is available on reload, since its already been loaded, so that's why it worked then.

    At this point I'm going to have to ask you to either purchase my book, or look elsewhere for your help with World of Warcraft addons. I am incredibly time limited, and quite generous, but I can't continue to help someone who has no affiliation with this website in the least.

    I understand my friend, anyway thank you for all the help they gave me throughout this time.

    May God bless you.