Util.effect on player

Hey guys I am working on a nutscript item and am trying to make a util.effect happen on a player when they equip the item. However, the util.effect is having trouble identifying the player. I am not sure to use this case. I’ve tried a lot of inputs and have yet to find one. All help is appreciated. Below is the code.



ITEM:hook("Equip", function(item)
    item.player:EmitSound("items/ammo_pickup.wav", 80)
    item.player:notify("You've transformed into a blood sucking beast!")
	print(VPoint)

    function ENT:Think()
		local vPoint = item.player:GetPos()
        local effectdata = EffectData()
        effectdata:SetOrigin(vPoint)
        effectdata:SetMagnitude(10)
        effectdata:SetScale(10)
        effectdata:SetRadius(20)
        util.Effect("TeslaZap", effectdata)
    end
end)


When I print vpoint I get “nil”.

The error given:



[ERROR] gamemodes/shatteredrealm/plugins/armorsets/items/armor/sh_healerdemonicarmor.lua:23: attempt to index global 'ENT' (a nil value)
  1. unknown - gamemodes/shatteredrealm/plugins/armorsets/items/armor/sh_healerdemonicarmor.lua:23
   2. unknown - gamemodes/nutscript/gamemode/core/libs/sh_item.lua:672
    3. func - gamemodes/nutscript/gamemode/core/libs/thirdparty/sh_netstream2.lua:117
     4. unknown - lua/includes/extensions/net.lua:32


[editline]4th August 2017[/editline]



ITEM.name = "Healer's Demonic Transformation Cloth"
ITEM.desc = "A magical piece of armor that transforms the wearer into a blood sucking beast. Gives incredible speed."
ITEM.model = "models/items/armors/player_armors/player_armor_wizard.mdl"
ITEM.width = 1
ITEM.height = 1
ITEM.outfitCategory = "armorset"
ITEM.price = 45000
ITEM.healersOnly = true

-- Armor specific attributes
ITEM.outfitCategory = "armorset" -- Outfit category, currently "armorset" should be the only one used
ITEM.playerModel = "models/vampirepiemp.mdl" -- The model to set of the player. We might want to add female/male variants later
ITEM.armorSkillMultiplier = 3 -- X * getData("Skill_ARMOR")
ITEM.armor = 500 -- Set Armor (armorSkillMultiplier * getData("Skill_ARMOR")) + armor
ITEM.armorspeed = 300


ITEM:hook("Equip", function(item)
    item.player:EmitSound("items/ammo_pickup.wav", 80)
    item.player:notify("You've transformed into a blood sucking beast!")
	print(VPoint)

    function item.player:Think()
		local vPoint = item.player:GetPos()
        local effectdata = EffectData()
        effectdata:SetOrigin(vPoint)
        effectdata:SetMagnitude(100)
        effectdata:SetScale(10)
        effectdata:SetRadius(20)
        util.Effect("Sparks", effectdata)
    end
end)


I think I fixed it but no effect is happening. But no errors either. So I am going to try a new effect.

Why are you putting the effect in a think function? You’re defining the function wrong, but if you just want the effect to happen once then you don’t want to use the think function. Just put the code outside of the function.

This should work:
[LUA]ITEM:hook(“Equip”, function(item)
item.player:EmitSound(“items/ammo_pickup.wav”, 80)
item.player:notify(“You’ve transformed into a blood sucking beast!”)

local effectdata = EffectData()
effectdata:SetOrigin(item.player:GetPos())
effectdata:SetMagnitude(100)
effectdata:SetScale(10)
effectdata:SetRadius(20)
util.Effect("Sparks", effectdata)

end)[/LUA]