Trying to integrate hook into a functions breaks the function

Hi I’m trying to call hooks whenever a prop gets un-/frozen but after running the code I can’t freeze anything anymore.


oldfrz = oldfrz or _R.PhysObj.EnableMotion

function _R.PhysObj:EnableMotion(bool)
    local ent = self:GetEntity( )
    if bool then
        hook.Call("EntUnfreeze",GAMEMODE,ent,self)
    else
        hook.Call("EntFreeze",GAMEMODE,ent,self)
    end
    self:oldfrz(bool)
end

  1. problem how can I make the hook control whether or not I can un-/freeze a prop if i return false in it?

hook.Call will return whatever function that it calls returns smth else than nil first

Haha thanks! (some of those solutions which are too easy to think of^^)

Also I solved my first problem by replacing the first line with:


_R.PhysObj.oldfrz = _R.PhysObj.oldfrz or _R.PhysObj.EnableMotion

Thread solved.