How would I make a player race event

Hello, how do you make a racing event for every 10 minutes that will prompt every player to join the race and with a countdown to 10 seconds remove the prompt and then start the race? I have no idea what to search so I can’t find solution. I’m not that experienced yet so help would be great,

serverscript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

local joinRaceEvent = ReplicatedStorage.Remotes.JoinRaceEvent

local playersInRace = {}

while true do
	task.wait(30)
	print("started")
	joinRaceEvent:FireAllClients()
	print("passed")
	joinRaceEvent.OnServerEvent:Connect(function(player)
		if player then
			table.insert(playersInRace, player)
		end
	end)
	print("passed2")
	print(playersInRace)
	--I have no idea what i'm doing
end

local:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local player = game:GetService("Players").LocalPlayer

local gui = script.Parent
local raceFrame = gui:WaitForChild("RaceFrame")
local timer = raceFrame:WaitForChild("Timer")
local joinButton = raceFrame:WaitForChild("JoinButton")

local remotes = ReplicatedStorage:WaitForChild("Remotes")
local joinRaceEvent = remotes:WaitForChild("JoinRaceEvent")
local raceTimer = remotes:WaitForChild("RaceTimer")

joinRaceEvent.OnClientEvent:Connect(function()
	print("race prompt started")
	gui.Enabled = true
	for i = 10, 0, -1 do
		timer.Text = i
	end
	gui.Enabled = false
	print("race join prompt end")
end)

joinButton.MouseButton1Click:Connect(function()
	joinRaceEvent:FireServer()
	print("fired")
end)

It is not a good idea to connect events in while loops, unless the connection will be disconnected. When the loop runs twice, the player will be added to the race list twice, and then three times on the third loop, etc. Instead, connect it elsewhere, and have the loop determine if it’s looking for volunteers for the race.

-- Server Race Message

local repstorage = game.ReplicatedStorage
local remote = repstorage.Remotes.JoinRaceEvent
local racers = {}

local hiring = false
task.spawn(function()
    while true do
        task.wait(30)
        hiring = true
        remote:FireAllClients(true) -- true = show message
        task.wait(30)
        remote:FireAllClients(false) -- false = hide message
        print(racers)
        hiring = false
        racemethod() -- start race here (will yield until race finishes)
    end
end)

remote.OnServerEvent:Connect(function(player)
    if hiring and not table.find(racers, player) then
        table.insert(racers, player)
        print(player, "entered the race!")
    else
        print("Cannot enter race.")
    end
end)
-- Client Race Message

local storage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer

local gui = script.Parent
local raceFrame = gui:WaitForChild("RaceFrame")
local timer = raceFrame:WaitForChild("Timer")
local joinButton = raceFrame:WaitForChild("JoinButton")

local raceremote = storage:WaitForChild("Remotes"):WaitForChild("JoinRaceEvent")

raceremote.OnClientEvent:Connect(function(enabled)
	gui.Enabled = enabled
	if enabled then
        for i = 10, 0, -1 do
            timer.Text = i
            task.wait(1)
        end
    end
end)

joinButton.MouseButton1Click:Connect(function()
	raceremote:FireServer()
end)