So yeah, I've been forgetting all the lua stuff we used to use before lua on attachables.
Code:
function Create(self)
for actor in MovableMan.Actors do
if SceneMan:ShortestDistance(self.Pos,actor.Pos,true) < 100 and actor.EquippedItem.PresetName == "Tactical Grenade Launcher" then
self.Parent = actor
end
end
end
function Update(self)
for actor in MovableMan.Actors do
if SceneMan:ShortestDistance(self.Pos,actor.Pos,true) < 100 and actor.Team ~= self.Parent.Team then
self.PinStrength = 99999
self.Vel = (actor.Pos-self.Pos)
self:GibThis()
end
end
end
It's just the old school way to find out who is the parent of the bullet (the script is attached to the bullet) and then ignoring the parent's team to explode against enemies. Basically some sort of proximity-detector with added directed blast.
The error I'm getting is at line 11 (the first if of function Update(self)), in which it says it can't compare nil with a number, which probably means it isn't detecting any parent and hence can't compare the non-existing parent's team with the soon-to-be-killed actor's team.
What the hell am I doing wrong?