0
votes

I have decompiled the old Pikmin add-on for Garry's Mod because it's producing the following error:

[ERROR] workshop/lua/sv_pikmin.lua:38: attempt to call global 'ValidEntity' (a nil value) 1. v - workshop/lua/sv_pikmin.lua:38 2. Call - lua/includes/modules/hook.lua:84 3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:279

This section of code is on line 38:

    local function DontToolMe(ply, tr, tool)
if (ValidEntity(tr.Entity) && tr.Entity:GetClass() == "pikmin_onion" || tr.Entity:GetClass() == "pikmin" || tr.Entity:GetClass() == "pikmin_model") then
    if (tool == "duplicator") then
        return false;
    end
end
return true;

end

Line 38 is specifically the "if" statement with the "ValidEntity" keyword.

I would like to somehow be able to update this fantastic add-on so we can use it along with the tool-gun.

I have the whole project here: https://drive.google.com/file/d/0Bwr6tf5HSyxyRXZ0c2VkQmEtU2M/view?usp=sharing

Thanks, Pikmin25.

1

1 Answers

2
votes

ValidEntity is not a function in your scope. Therefor you cannot call it.

I don't know where you got that function from and I'm no Gary's Mod expert. But the reference documentation lists a function IsValid(entity). Maybe you can use this instead as you are obviously trying to validate an entity.

So try to replace ValidEntity(tr.Entity) by IsValid(tr.Entity)