Basically the title.
local touching = false
local player = game:GetService("Players").LocalPlayer
local function onTouch(part)
local hum = player:FindFirstChild("Humanoid")
if hum then
touching = true
repeat
hum:TakeDamage(5)
wait(1)
until not touching
end
end
local function onTouchEnd(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum then
touching = false
end
end
script.Parent.Touched:Connect(onTouch)
script.Parent.TouchEnded:Connect(onTouchEnd)

2 comments
I don't think it will run onTouchEnd() because the repeat is running. This may not be the case though.
I have edited my answer and fixed your problem. Let me know if there are any other problems. Also, if I have solved your problem, please make sure to accept my answer.