Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I check if a data store async is nil when trying to check creates one?

Asked by
Uglypoe 557 Donator Moderation Voter
8 years ago

I tested this on a brand-new alternate account just to see what would happen. It's supposed to only run the code if that old entry has a value to it. However, it runs for new players even though it shouldn't. Is there a way to fix this? I'll elaborate more if needed.

local olddata = game:GetService("DataStoreService"):GetDataStore("Pokemon"):GetAsync("user_"..newPlayer.userId.."_Pokemon")
if (olddata ~= nil and olddata ~= "1") then
convertspecials(olddata,newPlayer)
end
0
The wiki says that if the key doesn't exist, it returns nil. However, even when I tested it on a brand-new account, it still fired the "convertspecials" function. Why?? Uglypoe 557 — 8y

Answer this question