I need help with my script

  1. What I want to achieve? A live countdown to a certain date.

  2. What is the issue? It counts to the date that is not stated and it wrong configured like it shows that there are 78 hours left and a day has 24 hours only…

  3. What solutions have you tried so far? I looked on the internet and asked other scripters and tried like 20 editions of the script.

local countdownGui = script.Parent
local countdownText = countdownGui:WaitForChild("CountdownText")


local day = os.time({year = 2021, month = 4, day = 4, hour = 11, min = 16, sec = 0})


while wait() do

	local secondsBetween = os.difftime(day, os.time())

	local seconds = secondsBetween % 60
	local minutes = math.floor(secondsBetween % (6060) / 60)
	local hours = math.floor(secondsBetween % (606024) / (6060))
	local days = math.floor(secondsBetween % (60602430) / (6060*24))

	local textString = days .. "d:" .. hours .. "h:" .. minutes .. "m:" .. seconds .. "s"
	countdownText.Text = textString

	if secondsBetween <= 0 then break end
end

Try this,

local countdownGui = script.Parent
local countdownText = countdownGui:WaitForChild("CountdownText")


local day = os.time({year = 2021, month = 4, day = 4, hour = 11, min = 16, sec = 0})

while wait() do
	local secondsBetween = os.difftime(day, os.time())
	local seconds = math.floor(secondsBetween)%60
	local minutes = math.floor(secondsBetween/60)%60
	local hours = math.floor(secondsBetween/3600)%24
	local days = math.floor(secondsBetween/86400)
	local textString = days .. "d:" .. hours .. "h:" .. minutes .. "m:" .. seconds .. "s"
	countdownText.Text = textString
	if secondsBetween <= 0 then break end
end

1 Like

Wont this countdown while your only in the game?

Right, this is only in game countdown.