Well, in terms of Lua as implemented in LotRO there's a lot wrong with that. I will try to explain line by line:
Originally Posted by griste
run if sourceGUID == UnitName("target") then
There is no "run" key word in the Lua language and no "run" feature in LotRO Lua.
It may be that another game's Lua implementation has a "UnitName" function but no such function exists in LotRO's implementation.
EDIT: There is a UnitName function in WoW's implementation but that is specific to WoW and does not exist in LotRO.
if spellname==("Blind") then
while not technically wrong, the parentheses are unneccessary as ("Blind") evaluates to "Blind" so this statement could be written as
if spellname=="Blind" then
As with "UnitName" above, there is no function "CastSpellByName" in LotRO's implementation of Lua - in fact, in LotRO, there is no way to programatically perform an action. The only way to perform an action in LotRO's Lua is to assign it to quickslot so that the end user can activate it by clicking. There is a CastSpellByName function in WoW's implementation but that is specific to WoW and does not exist in LotRO.
You have three block "end" statements but you only have two code blocks. It is possible that in another implementation of Lua with a "run" statement that an "end" is needed to close the "run" but since there is no such statement in LotRO's Lua, the last "end" is also an error.
So, to sum it up, it looks like you are asking for help with a Lua script that was not written for the LotRO implementation of Lua but rather for a different game's implementation, specifically WoW's implementation. Hopefully that answers your question. Is there something particular you are trying to implement for LotRO or were you just trying to test a code sample that you found somewhere and did not know why it doesn't work in LotRO's Lua?
If you are looking for help with a WoW script, you should probably try wowinterface.com which supports WoW and would be able to provide a better answer. I'm not sure but I believe in WoW that "run" is a macro command, "/run", in which case it should be followed by a single block of Lua code so you would need a "do" statement which would encapsulate the rest of the script and then the third "end" would be ok since it would be closing the block explicitly opened with a "do". That is, change the first line to:
/run do if sourceGUID == UnitName("target") then
but that is just a guess as I haven't written any scripts for WoW in many years so I really don't remember if that is correct for their implementation.