Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

It says argument 1 missing or nil... how do I fix this?

In my onJoin/onLeave script, the game runs into a problem. It tells me "Argument 1 missing or nil". This does not make sense to me, so my two questions are:

1 - What does this error mean? 2 - How can I fix this?

So first of all, this is the entire function:

function onPlayerJoin(Player) 
	local IMPRTNT = Instance.new('NumberValue')
	IMPRTNT.Parent = Player
	IMPRTNT.Name = 'CharType'
	
	local val = script.Parent.Help.PlayerHelp.Extra:FindFirstChild()
	val.Name = Player.Name
	val.Value = Player.Name
	if val.Parent.Parent.Parent.ReadyHelp.R1.Value == false then
		repeat
			wait()
		until script.Parent.Help.ReadyHelp.R1.Value == true
		val.Parent = val.Parent.Parent.P1
	else
		val.Parent = val.Parent.Parent.P1
	end
end 

The start, lines 2-4, inserts a value into the player for later use. The error occurs on line 6 where the programming tells the game to fetch a value to represent the player. It is supposed to do this and insert the player's information, but it says something about missing or nil. This may have to do with my use of the FindFirstChild function, but I cannot be sure. Feel free to comment and I will try to help. Thanks!

1 answer

This error means that there is a call to a function somewhere that has run into a problem because you haven't supplied it enough information. This specific error, is coming from line six where you make a call to FindFirstChild() with no arguments. FindFirstChild() takes one arguement: a string. You have not given it a string and it yields the error.

In order to fix it, you must give the FindFirstChild() function an argument that tells the name of the child that you are trying to find. I do not know what you are specifically trying to find from your post so I can't provide you with an exact solution but it would look something like this:

local val = script.Parent.Help.PlayerHelp.Extra:FindFirstChild("NameOfChild")

This discussion is preserved as it was. New answers, comments, and votes are closed.