Trying to restrict a STOOL

Hello, I am new to LUA and trying to code a simple script to prevent non admins from using a specific STOOL. I realize there is probably a better way to do this (and if you know how besides ASSMOD i would be interested… I know, wrong section, sorry) but i meant it as a learning exercise


local function WeaponEquip(wep)

function checkAdmin(ply)

     if ply:IsAdmin() then
          end
     else
          if wep:GetClass() == "tool_cratemaker" then
			wep:Remove()
			Player:Give("gmod_tool");
     end
 
end
hook.Add( "WeaponEquip", WeaponEquip )

I also get this error in console


autorun/test.lua:7: 'end' expected (to close 'function' at line 3) near 'else'

Any help would be appreciated

change


if ply:IsAdmin() then
          end
     else


to


if ply:IsAdmin() then
     else


Can’t have ends before an else statement, afaik.


if ply:IsAdmin() then return false else




function RestrictTool(ply,tr,tool)

if(tool == "tool_cratemaker" && !ply:IsAdmin()) then
return false
end


end

hook.Add("CanTool","RestrictCratemaker",RestrictTool)


hope that helps