Help with getting a number that is -1 every 5 rounds?

Im making a round system that will spawn a boss on rounds that are 1 less than 5, such as 4,9,14,19, etc.

this is what I have:

while true do
wait(0.5)
local round = 4
local g = round + 5 * math.floor(round / 5)
print("0 :",round,"[]",g)
if round == g then
print("1: ",round)
elseif round ~= g then
print("2: ",round)
end
end

as you can see this attempt didn’t go so well, perhaps someone could point me in the right direction?

1 Like

You can try adding another variable called “bossRound” to keep track of it.

So then you just need to do like this

--Before starting the loop
local bossRound = 0 

-- Inside the loop.
if bossRound == 0 and round == 4 then
      bossRound = bossRound + 1
      -- First boss round
elseif bossRound >= 1 and round == (4 + (5 * bossRound)) then
      bossRound = bossRound + 1
      -- Other boss rounds.
end
--Continue the loop.

and I wont need to keep adding to it for more rounds right?
also: as a side note, the rounds are expected to be endless, so it would have to keep adding up without adding more code for more rounds.

Here is wrote a small script for you:

local Round = 1
while true do
    wait(0.5)
    local LastestBossRound = 0
    
    local CurrentBossRound = math.floor((Round+1)/5) --// math.floor would convert numbers with decimals like 0.8 into 0, since every 5 rounds is the boss fight, then we would divide by 5, and because it's not 5, 10, 15, and it's 4, 9, 14, then we would increment one number. If the round is 4, then the number would be 1, if the round is 3 then the number would be 0
  
    if LastestBossRound ~= CurrentBossRound then --// If the lastest boss round (0) is not the same as the current boss round.
	    LastestBossRound = CurrentBossRound --// Convert the lastest boss round into the current one.
    	print("Boss Time")
    else
    	print("Pizza Time")
    end
    Round = Round + 1
end

I hope this helps you :+1:

Yeah thats what its meant to do. I got a if statement at the start to detect if there wasn’t a boss round yet and its in the 4th round.

The elseif condition is the detection of the boss rounds after the first one already happened.

(Just a note but I edited a simple thing in it.)

local round = 0

while true do
	wait(0.5)
	round += 1
	
	local isBossRound = ((round+1)%5 == 0)
	
	if (isBossRound) then
		local bossRound = math.floor((round+1)/5)
		print("Boss round:", bossRound)
	else
		print("Normal round:", round)
	end
end

I hope this example helps you

1 Like

this one works, thank you. :innocent:

1 Like