How do you stop a repeat until loop?

I want to stop a repeat until loop when a condition is met.

script:

game.ReplicatedStorage.events.test.OnServerEvent:Connect(function(player, trigger)
	if trigger == "Holding" then
		repeat
		wait(1)
		player.Character:FindFirstChild("Humanoid"):TakeDamage(2)
		until
		trigger == "NotHolding"
-- i want to stop the loop here, so the player stops taking damage
	end
end)

You need to store the player action outside the event to be able to detect a change to the value

Here is one example:

local PlayersHolding = {}
game.ReplicatedStorage.events.test.OnServerEvent:Connect(function(player, trigger)
	if trigger == "Holding" then
		PlayersHolding[player] = "Holding"
		table.insert(, player)
		repeat
			wait(1)
			player.Character:FindFirstChild("Humanoid"):TakeDamage(2)
		until PlayersHolding[player] == "NotHolding"
	elseif trigger == "NotHolding" then
		PlayersHolding[player] = "NotHolding"
	end
end)

Its not the best examble but it does the job