Kick command not showing proper time

Basically, this is my ban module:

function Aloe:GetBanStatus(player)
	local areBanned = BanData:GetAsync(player.UserId)
	if not areBanned then return false end
	local Arguments = areBanned.UnbanTime or {Years=0,Months=0,Weeks=0,Days=0,Hours=0,Minutes=0,Seconds=0}
	local Years = (Arguments.Years or 0)
	local Months = (Arguments.Months or 0)
	local Weeks = (Arguments.Weeks or 0)
	local Days = (Arguments.Days or 0)
	local Hours = (Arguments.Hours or 0)
	local Minutes = (Arguments.Minutes or 0)
	local Seconds = (Arguments.Seconds or 0)

	local years = ((365 * 7 * 24 * 60 * 60) * Years) 
	local months = ((12 * 7 * 24 * 60 * 60) * Months) 
	local weeks = ((7 * 24 * 60 * 60) * Weeks) 
	local days = ((24 * 60 * 60) * Days) 
	local hours = ((60 * 60) * Hours)
        local minutes = (60 * Minutes) 
	local seconds = (1 * Seconds)
	if not areBanned then
		return false;
	else
		if os.time() > areBanned.FinalTime then
			BanData:RemoveAsync(player.UserId);
			return false;
		else
			local str = [[
			You are currently banned!
			
			You currently have %d years, %d months, %d weeks, %d days, %d hours, %d minutes, %s seconds left on your ban!
			
			Appeal at: .gg/tappingworld!
			]]
			local final = string.format(str, years, months, weeks, days, hours, minutes, seconds)
			return final
		end
	end
end

function Aloe:Ban(player, Arguments)
	local Years = (Arguments.Years or 0)
	local Months = (Arguments.Months or 0)
	local Weeks = (Arguments.Weeks or 0)
	local Days = (Arguments.Days or 0)
	local Hours = (Arguments.Hours or 0)
	local Minutes = (Arguments.Minutes or 0)
	local Seconds = (Arguments.Seconds or 0)
	
	local years = ((365 * 7 * 24 * 60 * 60) * Years)
	local months = ((12 * 7 * 24 * 60 * 60) * Months)
	local weeks = ((7 * 24 * 60 * 60) * Weeks)
	local days = ((24 * 60 * 60) * Days)
	local hours = ((60 * 60) * Hours
	local minutes = (60 * Minutes)
	local seconds = (1 * Seconds)
	local UnbanTime = {
		Years = years,
		Months = months, 
		Weeks = weeks, 
		Days = days,
		Hours = hours,
		Minutes = minutes,
		Seconds = seconds,
		FinalTime = years + months + weeks + days + hours + minutes + seconds
	}
	
	BanData:SetAsync(player.UserId, UnbanTime)
	local str = [[
			You are currently banned!
			
			You currently have %d years, %d months, %d weeks, %d days, %d hours, %d minutes, %s seconds left on your ban!
			
			Appeal at: .gg/tappingworld!
			]]
	local final = string.format(str, years, months, weeks, days, hours, minutes, seconds)
	player:Kick(final);	
end

This is what the ban message looked like when I banned myself for 65 years:
image

2 Likes

image
Banned for 1 year 2 month 3 week 4 day 5 hour 6 minute 7 second.

Your formulas are completely off. I suggest you test some out and get some that work.

these are off:
	local years = ((365 * 7 * 24 * 60 * 60) * Years) 
	local months = ((12 * 7 * 24 * 60 * 60) * Months) 
	local weeks = ((7 * 24 * 60 * 60) * Weeks) 
	local days = ((24 * 60 * 60) * Days) 
	local hours = ((60 * 60) * Hours)
        local minutes = (60 * Minutes) 
	local seconds = (1 * Seconds)
1 Like

365 * 7 * 24 * 60 * 60 returns the os.time() year time, im not sure where to go from there

The problem here appears to be that you multiply your years by Arguments.Years when writing that UnbanTime in the table. Say for instance that you call :Ban with Years being equal to 1 - you then set the Years in the UnbanTime table to the # of years converted into the tables. You also have your formulas wrong.

I would reconsider rewriting this code to simply use a digit Unix time - you can then simply use the DateTime library from ROBLOX to handle the actual formatting.

Taking the year number and multiplying it by those numbers actually returns the number of years in seconds. Once again, you are then outputting this seconds number rather than the actual year count.

EDIT: wrong reply lol

1 Like

Are you being banned for the time you entered?

Something I will note is that numbers on roblox are a bit backwards. Once you hit a certain amount, they will end up decreasing to another number to save data. Iā€™d advise you alter them into strings where possible.

And, as @kaz_iaa said (second time I have responded to raid in like 30 minutes), you are using the values in seconds, at no point have you converted your seconds or used your previous arguments.