This script was given to me by RedcommanderV2, but I get an error when calling a command that i have inserted to the script after i editted it to call commands.

This part errors:

local function FindReason(MsgWords, StartNumber) 
	local Reason = {}
	for index, word in pairs(MsgWords) do
		if index >= StartNumber then
			table.insert(Reason, word)
		end
	end
	return(table.concat(Reason, ' '))
end

The Part That Calls It:

local Value = FindReason(MsgWords[3]) or ''

Error: ServerScriptService.Admin:76: bad argument #1 to 'pairs' (table expected, got nil) Stack Begin Script 'ServerScriptService.Admin', Line 76 - upvalue FindReason Script 'ServerScriptService.Admin', Line 172 Stack End

Any Help Would Be Appreciated!

1 comment

0

In your first code block, MsgWords is supposed to be a table that the for-loop on line 3 goes through. The other block should be the table "MsgWords" not the value of the key you are indexing.