I want to make a button slowly kill a player, but when they exit a radius, they will stop taking damage. Here is the code that I'm using to get a button to slowly kill a player:
clickDetector.MouseClick:Connect(function()
local h = hit.Parent:findFirstChild("Humanoid")
while true do
if (h ~= nil) then
h.Health = h.Health - 2
wait(1)
end
end
end)
But I still need to find a way on how to make it so that it stops after the player leaves a certain radius. What functions and services (and such) would I use?

2 comments
on a mouse click. it goes player and then character. so you would do local h = plr.Character:findFirstChild('Humanoid') In the parameters you would put plr
If you got the health decreasing and whatnot and just asking for the radius then I would suggest either using magnitude which can be difficult to use at times or use some other thing