Not sure why "Argument 1 missing or nil" error happens

script.Parent.Enabled = true
local player = game.Players.LocalPlayer
local teamModule = require(game.ReplicatedStorage.TeamModule)
local menuRemote = game.ReplicatedStorage.MenuRemote
local ts = game:GetService("TweenService")
local currentTeam = ""

function onPlayPressed()
	if currentTeam == "" then
		ts:Create(script.Parent.Blackout,,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0),{BackgroundTransparency = 0}):Play()
		local menuArgs = {
			["Reason"] = "Play";
			["RequestedTeam"] = currentTeam;
		ts:Create(script.Parent.Blackout,,Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0),{BackgroundTransparency = 1}):Play()
		script.Parent.MainBackground.Visible = false
		script.Parent.Enabled = false
function onTeamPressed()
	local playerGroups = teamModule.GetGroups(player)
	for i,v in pairs(teamModule.TeamInformation) do
		if playerGroups[i] then
			local template = script.TeamTemplate:Clone()
			template.Title.Text = tostring(i)
			template.Title.TextColor3 = v["PrimaryColor"]
			template.Name = i.."Team"
			template.Parent = script.Parent.MainBackground.TeamSelector.TeamList
				script.Parent.MainBackground.TeamInformation.TeamInfo.Text = v["Information"]
				script.Parent.MainBackground.TeamInformation.TeamName.Text = i
				currentTeam = tostring(i)
				print("Selected "..currentTeam)
	script.Parent.MainBackground.ButtonHolder.Visible = false
	script.Parent.MainBackground.TeamSelector.Visible = true
	script.Parent.MainBackground.TeamSelector.LineHorizontal.BackgroundTransparency = .2
	script.Parent.MainBackground.TeamSelector.Title.TextTransparency = 0
	script.Parent.MainBackground.TeamPlay.Visible = true
	script.Parent.MainBackground.TeamInformation.Visible = true


I’m just utterly stumped here, every time I run the onPlayPressed function it errors at line 6 (local currentTeam = “”) with “Argument 1 mission or nil”, any help is appreciated, thanks!

Can you post a screen shot of the error message?

Can you show the server script? You showed the client side, show the script that handles FireServer

Server Side:

local menuEvent = game.ReplicatedStorage.MenuRemote
local teamModule = require(game.ReplicatedStorage.TeamModule)

function onMenuFired(player,args)
	if args["Reason"] == "Play" then
		if teamModule.TeamInformation[args["RequestedTeam"]] and player:IsInGroup(teamModule.TeamInformation[args["RequestedTeam"]["GroupRequired"]]) or args["RequestedTeam"] == "Civillian" then
			player.Data.Main:WaitForChild("Team").Value = tostring(args["RequestedTeam"])
			player.Data.Main:WaitForChild("Team").Value = "Civillian"


The team module is just a table with group ids

Can you print args and tell me what it says

Remove the last semi colon in the menuArgs dictionary

Hmm… In my experience, that shouldn’t have anything to do with it. Something else is going on. The one thing that I see is that on the client, currentTeam is being set with a tostring, and that value is going through tostring again on the server. I tried duplicating it, and cant. It’s almost like the value is getting clobbered…OR there’s a problem with the left side of the assignment. It’s on the server side that’s complaining I think.

The error message says what function the error occurred it, so the error is on the server. Line 6 is the if statement, so the parameter getting passed to player:IsInGroup() is nil. Specifically, this is what’s throwing the error:


On the client, menuArgs.RequestedTeam is being set by currentTeam, which is a string. But on the server, you’re treating it as a nested table under RequestedTeam. That’s the only thing that I see that would cause a problem.

Did you try it? Cause its clealry sending it as nil so must have errored in creation

Can you tell me what args prints? I cant help you if i dont know what its printing.

No need to try it as I can follow the code. The variable currentTeam is assigned in onTeamPressed(). Looking at the assignment, currentTeam = tostring(i) sets it to type string. In that same script, on line 6, it’s declared and initialized as an empty string. In the function onPlayPressed(), it’s assigned to menuArgs.RequestedTeam, and it’s still a string. Then it gets sent to the server.

On the server, things change. We have args["RequestedTeam"]["GroupRequired"] within the if statement which is a nested table reference, but on the client it was sent as a string, not a table. That’s the problem. It’s a type mismatch.

I’m surprised that the LUA interpreter didn’t throw it as such. But, for whatever reason, in LUA, if you attempt a table access on a string, it returns nil. But if you try it on a number, it throws it as an error. A real compiler like clang or gcc won’t let you get away with it. At the very least it will print a warning.

And to satisfy your question, I just tried it in the studio command line. This is the result:


So basically, using table[nil] returns nil. Using table[-string-][-some reference-] also returns nil. But, using table[-number-][-some reference-] will throw an error. To me, that’s a bug within the LUA compiler and should be reported to Roblox. It’s not checking to see if the reference is actually a valid type when it’s resolving table references if the type is a string. Maybe it’s deliberate? I have no idea.


1 Like

Oh i was looking at the wrong line lmao. Like 6 is the one after that my bad

Yeah, it happens to the best of us. It always pays to have another pair of eyes look it over.


The error is occurring here, the IsInGroup() method expects a single argument (the group’s ID). You can verify this by printing teamModule.TeamInformation[args["RequestedTeam"]["GroupRequired"]].
The following code snippet produces an identical error.

local Game = game
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer

Thank’s so much man! I’m pretty sure I was just in a rush when writing this part of the code and didn’t fully realize what I typed. Thank’s again!

1 Like