Hello! I am trying to make a system that if you get a pet it unlocks in the gui . APARENTLY it works because the cat and dog have true but the unicorn have false.
This table is what I get from datastore, the length is 0 but it has information, also that For prints nothing, so this situation is confusing me a lot
print("table lenght: "..#tablePetHide)
print(tablePetHide["Cat"])
print(tablePetHide["Dog"])
print(tablePetHide["Unicorn"])
for i, v in ipairs(tablePetHide) do
print(v[1]) --nothing happens here
end
well the simplest way to do it was to see if they have at least 1 pet.
There wouldnt be a real need to get the entire length. Just check if it has 1 value.
if TablePetHide[1] == nil then
--- You dont have pets
else
--- You have pets
end
this would work, no matter the value put in.
its checking if it has any kind of value in TablePetHide[1]. [1] is the first assigned slot.
if theres a string or a number or another array, then [1] wont be nil.
however if there is no values in the array then [1] would be nil
No, it definitely will not work. You can’t access a dictionary with an integer key if there are no entries stored with integer keys. Go check for yourself if you don’t believe me. Here are all of the outputs in the original post, as well as your suggestion and mine.