Where to paste it? :O PLEASE HELP!

Hello internet!
I would like to know if i should make a .lua file with this code in it:

function GM:CanTool( ply, tr, tool )
if ( tool == “material” and IsValid( tr.Entity ) and tr.Entity:GetClass() == “prop_vehicle_jeep” ) then
return false
end
end

First of all. Does it work? And where should i put the lua?

If its for sandbox then make a file in lua/autorun/server paste it in there
If its for a custom gamemode then put it in a serverside file.

serverside file? :open_mouth: sry for being such newbie. im sry :confused:

Just create the file in lua/autorun/, name it whatever you want, with .lua extension and put the code in it.

Well. I get lua errors that says that “GM” is a nil value. please help

Oh, right, you gotta make it a hook, using hook.Add function.

could you show me please?

Here you have a Code from a Remove on Job Change code, see how you hook it, hope could help!
Its not the code you want to use!


hook.Add("OnPlayerChangedTeam", "asdf", function(ply)
        for k,v in pairs(ents.FindByClass("07sgmcrownviccvpi", "07sgmcrownvicuc", "c5500ambulance")) do
            if v.allowed and type(v.allowed) == "table" and table.HasValue(v.allowed, t) then continue end
            if v.SID == ply.SID then v:Remove() end
        end

end)


hook.Add("CanTool", "Dayruleisanidiot", function( ply, tr, tool )
    if ( tool == "material" and IsValid( tr.Entity ) and tr.Entity:GetClass() == "prop_vehicle_jeep" ) then
        return false
    end
end)