Hello there internet! I just added a new thing to my server. A thing so you cant material vehicles. But when i start the server i get lua errors. Wich says. GM is nil value. please help.
This is what the code is like:
function GM:CanTool( ply, tr, tool )
if ( tool == “material” and IsValid( tr.Entity ) and tr.Entity:GetClass() == “prop_vehicle_jeep” ) then
Second, you’re doing it wrong. You need to use a hook rather than actually using GM:function() - those are defined by the gamemode itself and can’t be accessed by other addons.
This is what you want to do:
function CanMaterialVehicles( ply, tr, tool )
if ( tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_vehicle_jeep" ) then
ply:ChatPrint("You're not allowed to use "..tool.." on "..tr.Entity:GetClass()..".")