Attempt to concatenate nil with string

  1. What do you want to achieve? Keep it simple and clear!
    Get rid of errors.
  2. What is the issue? Include screenshots / videos if possible!
    Attempt to concatenate nil with string - line 7
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    nothing…
local BanData = game:GetService("DataStoreService"):GetDataStore("Bans")

game.Players.PlayerAdded:Connect(function(player)
	if BanData:GetAsync(player.UserId) then
		local Length = BanData:GetAsync(player.UserId).Length
		local Date = os.date("*t")
		if Length >= Date.year..Date.month..Date.week..Date.day..Date.hour then -- problem here
			BanData:RemoveAsync(player.UserId)
		end
		player:Kick("YOU HAVE BEEN BANNED: REASON: ["..BanData:GetAsync(player.UserId).Reason.."] LENGTH TIME: ["..Length.."]")
	end
end)

week is not a key in os.date.

2 Likes