I don't know why I am getting the following error on the line marked on the script: Bad argument #3 to "Name (string expected,got nil) What is this and why does it happen? Is there anything wrong with the script or?

game.Players.PlayerAdded:connect(function(player)
       local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Skins")
    repeat wait() until player.Character

    player.Character:WaitForChild("PlayerSkins")
    wait(1)
    local stats = player.Character.PlayerSkins:GetChildren()
    player.Character.PlayerSkins.Script.AddValue:Fire()

    for i = 1, #stats do 
    stats[i].Name = datastore:GetAsync(stats[i].Name) --Error here.
    print(stats[i].Name.. "Loaded")
    end
end)

3 comments

0

What line does this error occur?

0

if stats[i].Name ~= nil then

0

It literally says in the script.. (Line 11)