func_mortartank help?

[lua]function ENT:FireMortar(ply)
for _, v in pairs(player.GetAll()) do
if v:Nick() == ply then
ply = v;

// yes i know the above code is ineffecient but i used it for testing purposes earlier

if !IsValid(ply) then return end;

mortartarget = ents.Create("ow_mortartarget"); // just a blank entity
// mortars have a crash bug where if you are below or almost below a target, it WILL crash the server 9 out of 10 times
self.opos.z = self.opos.z + 8000; // go 8000 units above normal position to prevent crash since its a vertical map and mortar will be near the bottom. also tried 100, does nothing different.

mortar = ents.Create("func_tankmortar")
mortar:SetPos(Vector(mortartarget:GetPos().x,mortartarget:GetPos().y,mortartarget:GetPos().z-100)) // cant make it go lower, or it will crash, 100 is just to be safe though
mortar:SetAngles(Angle(90, 0, 0));
mortar:SetKeyValue("iMagnitude", 100);
mortar:SetKeyValue("firedelay", "1");
mortar:SetKeyValue("warningtime", "1");
mortar:SetKeyValue("incomingsound", "Weapon_Mortar.Incomming");
    mortar:SetKeyValue("firestartsound", "Weapon_Mortar.Single");
mortar:Fire("SetTargetEntity", mortartarget, 0);
mortar:Fire("Activate", "", 0);
mortar:Fire("FireAtWill", "", 0);
mortar:Fire("Deactivate", "", 5);
mortar:Fire("kill", "", 5);
self.opos.z = self.opos.z - 8000; // reset position

No errors, no crashes, it just… doesn’t work. At all. And I have messed with it for the past hour, still nothing!

Add a print after the IsValid( ply ) check to see if that is where it’s stopping (most likely is)

What are you actually passing to the ENT:FireMortar function, a player entity or a nickname?

You’re comparing v:Nick() to (Most likely) an Entity

That would give an error, wouldn’t it?

It’s most likely he’s passing a string that doesn’t match any players on the server. Why the hell he passes a string and not the player entity is another question.

It also might be that the entity just doesn’t function with parameters he gave it.

It has nothing to do with the player part, guys. I added lots of prints, and it printed them ALL sucessfully.