1. Hi everyone. I am new to the scene of wow addon scripting, but i have previous experience with other programming languages. So i started to dabble cause i love wow. I started with a fairly easy addon to learn a few key elements. I have created a simple addon based off the tutorials found within WoWAddonStudio .... where if i select a unit target , or mouse over the unit target , it changes accordingly in the frame i am working with.

    The problem i have run into is that when i press escape, which in turn deselects all targets .. the addon throws an error nil value which makes sense to me , cause it can not display a name that does not exist. So having some prior knowledge to how a script works i have tried and tried again using a script like this ...

     function Frame1_OnEvent()
        if (event == "PLAYER_TARGET_CHANGED" && UnitName("target") != nil) then
            FontString1:SetText("Hello " .. UnitName("target") .. "!");
            end
        if (event == "UPDATE_MOUSEOVER_UNIT") then
            FontString1:SetText("Hello " .. UnitName("mouseover") .. "!");
            end
     end
    

    anyone that knows any amount of scripting should see right away what i am trying to accomplish , but apparently the syntax is completely invalid for what im trying to do.

    I need to test that there is a valid unitname or if there is not.... because if i deselect the target , that is when i get the error....

    Im sure this is a very simple snippet , but i have had zero success so far. Anyone able to help poor ole me out ? Thanks in advance!

  2. You have to give the SPECIFIC text of the error. Most likely you are reading it wrong, or it's saying something other than what you'd suspect. The easiest way to do something if the name exists is:

     if UnitName("target") then
       -- Do something if the name exists
     else
       -- Do something if it doesn't exist
     end
    

    Please post the specific error message.