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

What does "Argument 1 missing or nil" mean?

Asked by 9 years ago

I got a error while running a normal script.Please how you manged to fix it.

12:22:54.903 - Argument 1 missing or nil

12:22:54.904 - Script 'StarterScript.Script', Line 3

12:22:54.905 - Stack End

game.Players.PlayerAdded:connect(function(Player)
    Character = Player.Character
    Player:WaitForChild(Character)
    print(Character.Name)
    for Number,LocalScripts in pairs (script:GetChildren()) do
        LocalScripts:Clone().Parent = Character
        LocalScripts.Disabled = false
        print(Player.Name,"now has",LocalScripts)
    end

end)

1 answer

Log in to vote
1
Answered by
DataStore 530 Moderation Voter
9 years ago

When the player first joins, the character property of their player is nil. Currently, you're attempting to use WaitForChild on nil, hence it's giving you that output. You should also be aware that WaitForChild is used to wait for a direct child to be added, not for a property to change.

game.Players.PlayerAdded:connect(function(Player)
    Character = Player.CharacterAdded:wait()
    print(Character.Name)
    for Number,LocalScripts in pairs (script:GetChildren()) do
        LocalScripts:Clone().Parent = Character
        LocalScripts.Disabled = false
        print(Player.Name,"now has",LocalScripts)
    end
end)
Ad

Answer this question