0
votes

So I'm trying to get 3 things to save, But Even though when printing the values it works, It canot index them in the save script:

game.Players.PlayerRemoving:Connect(function(player)
    local stats = player:FindFirstChild(ns0)
    if not stats then return end
    local vals = {stats:FindFirstChild(nc0),stats:FindFirstChild(nc1),stats:FindFirstChild(nc2)}
    print(vals) -- returns: {...}
    print(vals[1], vals[2], vals[3]) -- returns: Cash NumberValue dropspeed
    print(vals[1].Value, vals[2].Value, vals[3].Value) -- returns: 0.1 0.02 9.5
    print(player.UserId) -- returns my user Id
    --if vals and vals[1] and vals[2] and vals[3] then
    if vals[1] and vals[2] and vals[3] then
        ds:SetAsync(player.UserId,{vals[0].Value, vals[1].Value, vals[2].Value}) -- attempt to index nil with Value error occurs here
    end
end)

Whats The problem?

1
vals[0] is nil.luther

1 Answers

0
votes

vals[0] was being indexed as nil, so i changed vals[0] to vals[1], vals[1] to vals[2] etc