Closed Andrew-Eathan closed 2 years ago
Should it? At what point can you get an invalid tool object?
Should it? At what point can you get an invalid tool object?
It doesn't really matter whether or not you can get an invalid tool object, the issue is in the title: IsValid(Tool) always returns false, which is flawed
https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/includes/util.lua#L229
This condition could be changed to true but who knows what that would break. Just don't send tools into IsValid: know what types you are dealing with instead of blindly sending data in.
How is it flawed? You are not meant to use IsValid
on every single variable, only in those scenarios where an object might be invalid, hence the name of the function.
IsValid
it will return false for more than just tools.
Details
Tools don't have an IsValid() method, and judging by the code for the global IsValid(), it's permanently returning false because of that
Steps to reproduce