I was using not, and not seems to activate when something is nil and false. Same goes for if, but values that exist and is true. Here's the code I'm trying to make, but it messes it up.
-- ban script
local bans = game:GetService("DataStoreService"):GetDataStore("Bans")
game:GetService("Players").PlayerAdded:Connect(function(plr)
-- trying to use it for nil
if not bans:GetAsync("player_" .. plr.userId) then
-- but it fires false and nil
-- how do i know
-- datastore throws an throttle error
-- and debug
print(bans:GetAsync("player_".. plr.userId)) -- false or nil
bans:SetAsync("player_" .. plr.userId, false)
end
if bans:GetAsync("player_" .. plr.userId) then -- still kicks if its false
print(bans:GetAsync("player_".. plr.userId)) -- false or true
plr:Kick()
end
end)

1 comment
say if bans:GetAsync("player_"..plr.UserId) then instead of line 5