Help with a LUA error for a short GMOD no-clip script

I really only have half an idea of what I’m doing… Any help is appreciated.**

Error:**
[ERROR] lua/autorun/server/antinoclip.lua:2: ‘=’ expected near ’ ’

  1. unknown - lua/autorun/server/antinoclip.lua:0

Code:
local function AntiNoclip(ply)
if ply:IsUserGroup(“A”,“B”) then return false end
end
hook.Add(“PlayerNoClip”,“AntiNoclip”,AntiNoclip)

It’s pretty simple, Player:IsUserGroup is a function of 1 parameter, you provide 2

Any way to provide two? I’m assuming you’re referring to my two separate groups, A & B.

You could try and use a table.


local groups = {
	"Group1",
	"Group2"
}

local function AntiNoclip(ply)
	if ply:IsUserGroup(groups) then
		return false
	end
end
hook.Add("PlayerNoClip","AntiNoclip",AntiNoclip)

That would provide a “String expected, got table” error.

If you want multiple groups, do this:


local groups = {
	"A",
	"B",
	--etc
}
hook.Add( "PlayerNoClip", "AntiNoclip", function( ply )
	if table.HasValue( groups, ply:GetUserGroup() ) then return false end
end )

Or use the code in the reply below me, it’s more efficient

Ideally you should do this:



local ranks = {
    superadmin = true,
    admin = true
}

-- in your hook or function or whatever
if ranks[pl:GetUserGroup()] then
    -- return whatever here
end