Empty DataStore value?

What’s an empty datastore equal to? I would assume ‘nil’ but I coded to test it out, an if statement with the expression [if banned == false then…] and [if banned == nil then…] both ran successfully. The banned variable was accessing a DataStore with a player’s UserId who has never played the game, hence no data for that key.

Edit: I also tried printing the variable ‘banned’ but it crashed my script, I got no output.

What’s an empty datastore equal to?

You wouldn’t use this said way of checking for a ban like this. In this way you are describing you are getting the entire datastore.

INSTEAD:

local Return = DATASTORE:GetAsync(<tuple> KEY)

if Return == nil then
     -- Not Banned
else
     -- Banned
end
1 Like