Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Serverside Modding => Topic started by: Kobiesan on May 23, 2017, 07:32:28 am

Title: Attempt to call method 'GetTarget' (a nil value)
Post by: Kobiesan on May 23, 2017, 07:32:28 am
I have this dummy script for a spell that strangles the target. I've attempted to do this by using this dummy script (eluna):

Code: [Select]
local function onCast(effectIndex, spell)
local target = spell:GetTarget()
if (spell:GetTarget():IsPlayer() == true) then
while player:IsCasting(81076) do
target:EmoteState(474)
end
end
end

RegisterPlayerEvent(PLAYER_EVENT_ON_SPELL_CAST, onCast)

However, when it's cast I get a "Attempt to call method 'GetTarget' (a nil value)" does anyone know what this error means?
Title: Re: Attempt to call method 'GetTarget' (a nil value)
Post by: Kaev on May 23, 2017, 09:40:47 am
Your argument spell is nil/null. Error says you can't get the target from something that doesn't exist. Make sure spell is not nil/null, e.g. by adding if (spell) then {code} end
Title: Re: Attempt to call method 'GetTarget' (a nil value)
Post by: Kobiesan on May 23, 2017, 08:00:08 pm
Your argument spell is nil/null. Error says you can't get the target from something that doesn't exist. Make sure spell is not nil/null, e.g. by adding if (spell) then {code} end

Can you elaborate a bit more?