Attempt to index function with table?

I couldn’t find any posts about this error anywhere, so here I am. The code below is a script that’s supposed to give you chat tag when you type in the chat.

local players = game:GetService("Players")
local marketplaceService = game:GetService("MarketplaceService")
local chatService = require(game.ServerScriptService:WaitForChild('ChatServiceRunner'):WaitForChild('ChatService'))

local admins = {...} -- there are UserIDs here, I just chose to not show them
local moderators = {...} -- same thing here, and no, the problem isn't the UserIDs

chatService.SpeakerAdded:Connect(function(plr)
	local speaker = chatService:GetSpeaker(plr)

	-- Administrator
	for i, v in pairs[admins] do
		if plr.UserId == v then
			speaker:SetExtraData('Tags', {{TagText = 'ADMIN', TagColor = Color3.fromRGB(133, 230, 216)}})
		end
	end
	
	-- Moderator
	for i, v in pairs[moderators] do
		if plr.UserId == v then
			speaker:SetExtraData('Tags', {{TagText = 'MOD', TagColor = Color3.fromRGB(230, 128, 128)}})
		end
	end
end)

This is the error that it gives:
ServerScriptService.Player Scripts.Chat Tags:12: attempt to index function with table

I don’t know that much about how tables work so the problem might be really easy to solve, I wouldn’t know though.

1 Like

You need parentheses, not bracketrs, when using pairs.
pairs(moderators)

Oh, I didn’t realize that. Thanks! :sweat_smile: