I want to do: if hero has item(name of item any) then hero get ability from sven can anyone see whats wrong here PLS


function GiveBlinkDagger (hero)
if hero:HasItemInInventory("item_Maric_peder", true, true) then
local dagger = GetAbility("sven_storm_bolt", hero, hero)
dagger:SetPurchaseTime(0)
hero:GetAbility(dagger)
end
end

function OnHeroPicked (event)
local hero = EntIndexToHScript(event.heroindex)
GiveBlinkDagger(hero)
end