How to damage player according to game phase (beginning, middle, end) during round countdown

Code:

local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")

local UpdateCountdown = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("UpdateCountdown")

local RoundStarted = game:GetService("ReplicatedStorage"):WaitForChild("RoundStarted").Value

while true do
	
	for secs = 10,0,-1 do
		
		Status.Value = "Starting in " .. secs .. "s"
		
		task.wait(1)
		
	end
	
	task.wait(2)
	
	RoundStarted = true
	
	for s = 240,0,-1 do

		local mins = math.floor(s / 60)
		
		local secs_remaining = s % 60
		
		UpdateCountdown:FireAllClients(string.format("%d:%02d", mins, secs_remaining))
		
		task.wait(1)

	end
	
	RoundStarted = false
	
	task.wait()
	
end

So the countdown is the for s = but its a for loop so i cannot damage a player there bc i want to lower the damage interval at 1 min to be 1 seconds instead of 2 for damaging and change the damage amount

1 Like

Would something like this do what you want?


for s = 240,0,-1 do

		local mins = math.floor(s / 60)
		
		local secs_remaining = s % 60

        if s >= 60 then
            if s % 2 == 0 then --every n seconds, in this case 2 seconds 
                damagePlayer(5) --your damage player function, the parameter is the amount of damage
            end
        else
            damagePlayer(10)
        end

		
		UpdateCountdown:FireAllClients(string.format("%d:%02d", mins, secs_remaining))
		
		task.wait(1)

	end