0

# How to make a button slowly kill a player? (More info in desc.)

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?

0
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 malachiRashee 7 — 4d
0
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 Rayguyban2 54 — 4d

0
A_Mp5 146
4 days ago

if im getting you right, this is what you want?

    clickDetector.MouseClick:Connect(function()
local healthrange = --what health you want them to end up with
local h = hit.Parent:findFirstChild("Humanoid")
repeat
if (h ~= nil) then
h.Health = h.Health - 2
wait(1)
until h.Health == healthrange
end
end)