Dividing being weird

Might get shadowbanned again but,
I need help with a countdown system. I have this text that displays the numbers into minutes, so when its 1 minute remaining, it keeps counting down (with decimals) all the way down to zero. The thing is, it makes these really weird nonsensical numbers right after it prints a normal quotient.

VIDEO

SCRIPT

local internalClockMin = 60
local countDown = 60
local countValue = holder.Value

while task.wait(1) do
	countDown -= 1
	internalClockMin = countDown/internalClockMin
	print(internalClockMin)
	countValue.Value = internalClockMin
	emoteText.Text = "next emote in "..string.format("%.2f", internalClockMin).." minutes..."
	
	if countDown <= 0 then
		countDown = 60
	end
end
1 Like

it’s becuase you keep changing internalClockMin from 60 to random decimals.

local internalClockMin = 60
local countDown = 60
local countValue = holder.Value

while task.wait(1) do
	countDown -= 1
	clockMin = countDown/internalClockMin
	print(clockMin)
	countValue.Value = clockMin
	emoteText.Text = "next emote in "..string.format("%.2f", clockMin).." minutes..."
	
	if countDown <= 0 then
		countDown = 60
	end
end
1 Like

either use my code:

local duration = 60
local cntr = 60
local countValue = holder.Value
local function convert(seconds)
  return string.format("%01d:%02d", (math.floor(seconds / 60)), (math.floor(seconds % 60)))
end

while task.wait(1) do
  cntr -= 1
  countValue.Value = convert(cntr) --// idk if countValue is a number val or a string val (adjust on your need)
  emoteText.Text = `next emote in {convert(cntr)} minutes...`
  if cntr <= 0 then cntr = 60 end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.