Here is a script that slowly does damage while the player is in it. Unfortunately it doesn't work all the time. I put it in a block and put the blocks down different places so when the player walks through it it does damage.
local damage = 1
local touched
local timebeforeotherdamage = 1
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if touched == false then
touched = true
repeat
if touched == true then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
end
wait(timebeforeotherdamage)
until
hit.Parent.Humanoid.Health == 0
end
end
repeat
wait()
until
touched == false
end)
script.Parent.TouchEnded:Connect(function(hit)
touched = false
end) ~~~~~~~~~~~~~~~~~
sometimes it will do a little damage, but when you go out of the block and back in, it does A LOT. The code looks fine to me so I don't know whats wrong...

5 comments
Use FindPartsInRegion3 (https://developer.roblox.com/en-us/api-reference/function/WorldRoot/FindPartsInRegion3) instead, it is way more reliable in this situation.
I will just warn you guy I'm still learning, so talk to me like a 5 year old
A region3 is made by specifying the top right and bottom left points of the box you want to do damage in. Once you have the region made, you can find parts in it and do damage to the humanoid.
I would highly suggest Region3s, to learn how to get players in a Region3, a good example is AlvinBlox's Robbable Bank Tutorial, which includes the use of region3s.
ok