Help dont know where to place the code


local staff = {
	"Moderator" = true,
	"Moderator+" = true,
	"T-Moderator" = true,
	"T-Moderator+" = true,
	"admin" = true,
	"Admin+" = true,
	"T-Admin" = true,
	"T-Admin+" = true,
	"Head-Admin" = true,
	"superadmin" = true,
	"Ejer" = true
}

local votecom = {
	ulx.votemute = true,
	ulx.votegag = true,
	ulx.votekick = true,
	ulx.voteban = true
}

local players = player.GetAll()

local staffon = players:IsUserGroup(staff) 

function lock_com(calling_ply)
	if calling_ply:IsUserGroup(VIP) do
		votecom = true and staffon > 3 then
			return false
			ULib.tsayError( calling_ply, "There is more than 3 staff members online ask them to help instead", true )
		end
	end
end

Where should i place this code and will it work pretty new to lua
It should block the ulx commands in votecom when there is more than 3 staff online

This code won’t work. The syntax has a couple of errors. For example:

you’re doing



if something do

it should be

if something then


Your votcom table is not in quotes.

[lua]players:IsUserGroup(staff)[/lua]

You never define what players is, and you need to do a loop to do what you are trying to do, which is count all online staff members. The syntax is also incorrect. If you are trying to check if their rank is in the table, you should do something like this inside a loop:

[lua]if staff[v:GetUserGroup()] then …[/lua]

[lua]local staffon = players:IsUserGroup(staff) [/lua]
This returns a bool, not a number.

[lua]function lock_com(calling_ply)[/lua]
You should always try to localize your functions when you can.

[lua]calling_ply:IsUserGroup(VIP) [/lua]

VIP needs to be in quotes

[lua] votecom = true and staffon > 3 then[/lua]

You’re missing an if, and votecom cant be true, it is a table.

You also never account for new staff getting on, or old staff getting off. I would put in some hooks for playerconnect and playerdisconnect, see if they are staff, then add or substract from my staffon variable.

You also never actually run the code. You need to hook this into a ULX hook or something. I think there is a hook that is called when a command is ran. Check if the command being run is the one you want to affect then go on from there.

Can you show me how you would do?

They literally both just told you what is wrong, use their advice and paste your new code with their changes if it doesn’t work