Help with Countdown Script not kicking people

Hello! I need help, and it’s concerning this script

local newYear = os.time({year = 2022, month = 10, day = 9, hour = 9, min = 17, sec = 0})


while wait(1) do

	local currentTime = os.time()

	local timeDiff = newYear - currentTime


	local d = math.floor(timeDiff/60/60/24)
	local h = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24))/60/60))
	local m = string.format("%0.2i", math.floor((timeDiff - (d*60*60*24) - (h*60*60))/60))
	local s = string.format("%0.2i", timeDiff - (d*60*60*24) - (h*60*60) - (m*60))
	local formattedTime = h .. ":" .. m .. ":" .. s

	script.Parent.CountdownText.Text = timeDiff <= 0 and "00:00:00" or formattedTime

	if timeDiff <= 0 then
		for _,v in pairs(game.Players:GetPlayers()) do
                         v:Kick("test")
                end
		break
	end
end

I’ve seen countless people use this script and it works flawlessly, but it doesn’t work for me.

Basically, when the timer reaches zero, its supposed to kick all the players in all servers, then break the loop. When I do play it and test it out, it just doesn’t work. It just loops the timer again from 00:00:00:00, to 23:23:59:59, and I don’t know what to do

Idk if I maybe bugged it, or just simply broke it. If anyone can help me, thank you in advance!

1 Like

Is this a server or a local script?

I tried this script and it works fine

Where’s the issue at ?

This text will be blurred

Nice going

I need to see where its placed at.

maybe the problem is that if ‘timeDiff’ will be equal to or less than zero, then the year will be 0000. you can try

if timeDiff<=5148440 then

BUT, this will not affect the day and year, that is, it will only work on the day that is written in the ‘newYear’ variable

1 Like

True though, but the year 0000 is not a thing.

The script is inside a server script
.
.

How? I doesnt work for me though :confused:

Sorry If i didnt reply on time, I was busy hehe.