Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
tber8 37
6 years ago

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

Log in to vote
1
Answered by
RayCurse 1518 Moderation Voter
6 years ago

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")
Ad

Answer this question