How to spawn balls in every 200 seconds?

How would I spawn balls in every 200 seconds instead of saying if minutes == 200 etc etc

Here is the script:

for minutes=1, 400 do
	timer.Text = "Timer: " .. minutes
	status.Text = ""

	if minutes == 200 then
		
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		
		
		status.Text = "Half Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			
			game.Workspace.Balls:Destroy()
		end
	end
	if minutes == 400 then
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		
		status.Text = "Full Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			
			game.Workspace.Balls:Destroy()
		end
	end
	wait(minuteLength)
end

add a while loop and wait(200) and that should do it if i understood your problem correctly

im having problems with a while loop

while task.wait(200) do
--// code... eg. spawn the ball
end
if minutes % 200 == 0 then

Use the modulo operator, it returns the remainder from a division, in this case we’re checking if when diving “i” by 200 the remainder is 0.

for minutes=1, 400 do
	timer.Text = "Timer: " .. minutes
	status.Text = ""
	if minutes % 200 then
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		status.Text = "Half Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			game.Workspace.Balls:Destroy()
		end
	end
	if minutes == 400 then
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		status.Text = "Full Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			game.Workspace.Balls:Destroy()
		end
	end
	wait(minuteLength)
end

works but only problem is, ball spawn in at 0 seconds, 2 seconds, 4 seconds etc

I’d check here, since using wait(1) doesn’t accurately wait 1 second if a player is lagging.

Wrong thread, I didn’t mean to post here.

for minutes=1, 400 do
	timer.Text = "Timer: " .. minutes
	status.Text = ""
	if 200 % minutes == 0 then
		print("HI")
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		status.Text = "Half Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			game.Workspace.Balls:Destroy()
		end
	end
	if minutes == 400 then
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
		end
		game.ServerStorage.Balls:Clone().Parent = workspace
		status.Text = "Full Time"
		resetBall(60)
		for index, player in next, playersService:GetPlayers() do
			player:LoadCharacter()
			game.Workspace.Balls:Destroy()
		end
	end
	wait(minuteLength)
end

I’ve replied to the other thread.