I’m trying to figure out if this is a big deal or not.
I have a Datastore with a couple values in it. I am using an Array.
This is how I load it.
local data = {}
local success, errormessage = pcall(function()
data = clicksdata:GetAsync(player.UserId)
end)
if success then
print ("load success")
lifekills.Value = data[1] or 0
lifepoints.Value = data[2] or 0
else
print (errormessage)
end
Thing is, I get an error when a player enters the game for the first time and I understand why, because the array isn’t saved yet… it is NIL. When the player exits the game for first time it creates the array and when he reenters it exists, and there is no error anymore.
Is this normal? I figured by putting the “or” in lifekills.Value = data[1] or 0,
it would set it to 0 if nil.
Any ideas?