Need help with adding staff groups to tool restriction code.

I have already tried doing this myself, but for some reason the code only allows one group to be defined as donator. Sorry I’m all noob at this lua, but help is appreciated.

Aside from VIP, I need the groups moderator, admin, and superadmin added.


 local tools = {
	"axis",
	"ballsocket",
	"stacker",
	"elastic",
	"lamp",
    "elastic",
	"hydraulic",
	"motor",
	"muscle",
	"pulley",
	"rope",
	"slider",
	"winch",
	"balloon",
	"emitter",
	"hoverball",
	"lamp",
	"thruster",
	"weight",
	"wheel",
	"eyeposer",
	"faceposer",
	"finger",
	"inflator",
	"trails",-- just add another entry to this table with the tools you want restricted from the donator rank
}

function RestrictTool(ply,tr,tool)
	if table.HasValue(tools,tool) and not ply:CheckGroup("vip") then -- checkgroup checks to see if you inherit from donator - so anything inheriting from it is able to use the tool too
		ply:ChatPrint("You need to donate to use: \""..tool.."\"") -- change this to whatever
		return false
	end
end

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

Use or statements with the CheckGroup.

I tried this. Didn’t work though. Can you please write it for me. I’m not a coder sorry. :confused:


function RestrictTool(ply,tr,tool)
	if table.HasValue(tools,tool) and not ply:CheckGroup("vip") or ply:CheckGroup("superadmin") or ply:CheckGroup("moderator") or ply:CheckGroup("admin") then