Issue with CreateUnitByName returning a nil value

I've been using some of pizzalol's spell library lua code to try and make my own custom ability, however I can't get past this one error.

local dummy = CreateUnitByName("npc_dummy_unit", target_point, false, caster, caster, caster:GetTeam())
dummy:AddNewModifier(caster, nil, "modifier_phased", {})

Error: "attempt to index local 'dummy' (a nil value).
This is from pizzalol's chronosphere code. I tried just using all of his code for chronosphere to see if I had messed something up, but his runs into the same error. Any help would be appreciated.

Comments

  • Hi, CreateUnitByName works this way: CreateUnitByName(, , <do u wanna create ur unit not directly in chousen point but near it if this place isn't empty>, , , )

    Mistakes in ur code could be: 1) There are no unit with name "npc_dummy_unit" in ur npc_units_custom.txt file (seems like it's not a base Dota unit name) 2) "target_point" variable not a Vector 3) errors with "caster" variable like: u didn't use it before and caster is nil; or caster is a name of caster, not caster as unit; ect.

  • Hi, CreateUnitByName works this way: CreateUnitByName(, , <do u wanna create ur unit not directly in chousen point but near it if this place isn't empty>, , , )

    Mistakes in ur code could be: 1) There are no unit with name "npc_dummy_unit" in ur npc_units_custom.txt file (seems like it's not a base Dota unit name) 2) "target_point" variable not a Vector 3) errors with "caster" variable like: u didn't use it before and caster is nil; or caster is a name of caster, not caster as unit; ect.

  • em, part of my comment was deleted? well see how does CreateUnitByName works here: https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/API/Global.CreateUnitByName