Well, it would of been more helpful if you made it clear that you wanted the destruction to happen at End Phase in your first post. And your effect is fine for the most part. I think you got it right with "TRIGGER" instead of "QUICK", but you code needs the phase you want the effect to happen...
--card
function c99999999.initial_effect(c)
--activate
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e1)
--cant atack lv
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_CANNOT_ATTACK)
e2:SetRange(LOCATION_SZONE)
e2:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e2:SetTarget(c99999999.atktarget1)
c:RegisterEffect(e2)
--cant atack rank
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_CANNOT_ATTACK)
e3:SetRange(LOCATION_SZONE)
e3:SetTargetRange(LOCATION_MZONE,LOCATION_MZONE)
e3:SetTarget(c99999999.atktarget2)
c:RegisterEffect(e3)
--Self destroy
local e4=Effect.CreateEffect(c)
e4:SetCategory(CATEGORY_DESTROY)
e4:SetDescription(aux.Stringid(99999999,1))
e4:SetType(EFFECT_TYPE_TRIGGER_F+EFFECT_TYPE_FIELD)
e4:SetCode(EVENT_PHASE+PHASE_END)
e4:SetRange(LOCATION_SZONE)
e4:SetCondition(c99999999.descon)
e4:SetTarget(c99999999.destrg)
e4:SetOperation(c99999999.desop)
c:RegisterEffect(e4)
end
function c99999999.atktarget1(e,c)
return c:GetLevel()>=4
end
function c99999999.atktarget2(e,c)
return c:GetRank()>=1
end
function c99999999.descon(e,tp,eg,ep,ev,re,r,rp,chk)
local lp=Duel.GetLP(tp)
return lp>=2000
end
function c99999999.destrg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsDestructable() and c:IsFaceup() end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,c,1,0,0)
end
function c99999999.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsRelateToEffect(e) and c:IsFaceup() then
Duel.Destroy(c,REASON_EFFECT)
end
end
So, I added "PHASE_END" to your SetCode. And just for good measures, I added "EFFECT_TYPE_FIELD" to your SetType, based off another card script that has an effect that happens at the End Phase.