So first of all this isn't my admin script, I just needed a way to use GroupIds for obvious reason. But I'm trying to make a Command "3h" basically adds 3 points to a scoreboard, but I have no clue how to do it. Due to the fact of how this script is setup. Is there a way to bypass the malformed number error?

local Admins = {
	"gage7252002"; -- Username example
	17614882; -- User ID example
	-- {GroupId = 0000;RankId = 255;} -- Group example
}
local Prefix = ""

local Players = game:GetService("Players")

local Commands = {}

Commands.print = function(Sender,Arguments)
	local Message = table.concat(Arguments," ")
	print(Message)
end



Commands.3h = function(Sender,Arguments)
	game.Workspace.GuiFolder.OneScore.Value = game.Workspace.GuiFolder.OneScore.Value +3
end


local function IsAdmin(Player)
	for _,Admin in pairs (Admins) do
		if type(Admin) == "string" and string.lower(Admin) == string.lower(Player.Name) then
			return true
		elseif type(Admin) == "number" and Admin == Player.UserId then
			return true
			elseif type(Admin) == "table" then
			local Rank = Player:GetRankInGroup(Admin.GroupId)
			if Rank >= (Admin.RankId or 1) then
				return true
			end
		end
	end
	return false
end

local function ParseMessage(Player,Message)
	Message = string.lower(Message)
	local PrefixMatch = string.match(Message,"^"..Prefix)
	
	if PrefixMatch then
		Message = string.gsub(Message,PrefixMatch,"",1)
		local Arguments = {}
		
		for Argument in string.gmatch(Message,"[^%s]+") do
			table.insert(Arguments,Argument)
		end
		
		local CommandName = Arguments[1]
		table.remove(Arguments,1)
		local CommandFunc = Commands[CommandName]
		
		if CommandFunc ~= nil then
			CommandFunc(Player,Arguments)
		end
	end
end

Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message,Recipient)
		if not Recipient and IsAdmin(Player) then
			ParseMessage(Player,Message)
		end
	end)
end)

1 comment

0

Variables cannot start with a number. Line 19 would have to be Commands.h3 or something.