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

What does "Argument 1 missing or nil" mean?

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

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)

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