Os.date() not working?

Hello, I want to make a game with a membership system, that the membership expires after the time is over, but it doesn’t work.

Script:

game.Players.PlayerAdded:Connect(function(player)
local dates = os.date("*t")
local data = adatastore:GetAsync(player.UserId) --adatastore is already declared.
if data.ExpireDay >= dates["day"] and data.ExpireMonth >= dates["month"] and data.ExpireYear >= dates["year"] then
	--Script that runs when it is expired
	print("Expired")
end)

For some reason it always prints “Expired”, but the Membership is expiring in one month.

There’s nothing we can know for sure from this script. You need to check two things and see your data.

  1. Output both variables you are comparing. See what they actually are in the output.
  2. Output the “types” of those variables (string vs number) to make sure you’re comparing the right types.
1 Like

I think you mixed them up, it should be dates[“day”] >= data.ExpireDay not the other way around.

if dates["day"] >= data.ExpireDay and dates["month"] >= data.ExpireMonth and dates["year"] >= data.ExpireYear then
	--Script that runs when it is expired
	print("Expired")
end)
2 Likes